๐Ÿš€Getting Started

The Witnet SDK offers a comprehensive range of NPM packages tailored to various Web3 environments and programming languages, ensuring you have the right tools for your specific use case.

Witnet SDK packages

Javascript and Typescript developers willing to interact with the Witnet blockchain.

Developers willing to report notarized oracle queries from the Witnet blockchain into smart contracts in EVM-compatible chains, get smart contracts to build verifiable oracle queries on-chain, or pull them off from the Witnet blockchain. Embeds @witnet/sdk.

Devops and devs willing to leverage, query or autonomously report notarized price feed updates, subsidized or not by the Witnet Foundation. Embeds: @witnet/sdk and @witnet/sdk-solidity.

In certain back-end environments, though, you might prefer to run your own Witnet nodes as to avoid relying on third-party Wit/RPC providers.

Witnet is a totally permissionless and Proof-of-Stake blockchain, and the requirements for running a node are surprisingly low. You don't even need to stake $WIT into your nodes if just willing to use them for transmitting transactions or fetching data from the blockchain. Becoming a Witnet validator could easily sustain the cost of running nodes, nonetheless. Learn how to setup, stake and run a Witnet node here.


Package @witnet/sdk

Prerequisites

  • Node.js >=18.17.0

Installation

$ pnpm add @witnet/sdk

Importing the SDK library

const { assets, utils, Witnet } = require('@witnet/sdk') 

Embedded binaries

This package embeds an executable that allows you to interact with the Witnet blockchain and even manage your own $WIT coins and Radon assets (i.e. customized oracle queries and web data sources), from the command line. It also allows dry-running oracle data queries, locally.

$ pnpm witnet --version

Setting up the environment

Two environment variables are required to interact with the Witnet blockchain:

  • WITNET_SDK_PROVIDER_URL

  • WITNET_SDK_WALLET_MASTER_KEY

WITNET_SDK_PROVIDER_URL

URL of the Wit/RPC endpoint that will provide both information about the Witnet network, and the transmission of transactions signed in Javascript.

This URL can correspond to that of any validator or archive nodes in the Witnet network (as long as the corresponding http/rpc port is reachable), or any of the public-domain endpoints provided by the Witnet Foundation:

Pubiic Networks
Wit/RPC Providers
Network id
Description

Witnet Mainnet

https://rpc.witnet.io

0x9FED

Where Wit/oracle queries get notarized for real, and results forever stored into the Witnet blockchain. Transactions get paid in real $WIT coins.

Witnet Testnet

https://rpc-testnet.witnet.io

0x2845

Only for testing purposes. Transactions get paid in $TWIT coins with no market value.

If using the Witnet Public Testnet for testing out transactions or notarization of oracle queries, please join the Witnet Discord channel and ask for getting airdropped with some $TWIT testing coins for free.

WITNET_SDK_WALLET_MASTER_KEY

In order to derive Witnet accounts, compose and sign transactions in Javascript, a valid private key in XPRV format must be provided, either exported from a Witnet node, or from the myWitWallet or the Sheikah wallet applications.

Master keys exported from myWitWallet get encrypted with a password.

Encrypted master keys requires the password to be specified in Javascript, or typed every time the CLI binary is asked to sign a transaction. If deemed necessary, decrypt master keys by following these steps:

  • Run $ npx witnet wallet decipher.

  • Copy the XPRV string exported from myWitWallet and paste it into the console.

  • Enter the password used when exporting the master key.

Smoke tests

Checklist
Commands

Verify the actual Witnet provider and network you're connecting to.

$ npx witnet network provider

The Wit/RPC provider should be operational and synced.

$ npx witnet network syncStatus

You should be able to operate with the same Witnet address/es as the one/s available on whatever app, or node, where the master key was imported from.

$ npx witnet wallet accounts

Last updated

Was this helpful?