๐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.
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.
You don't need to run a Witnet node, stake $WIT coins, or pay subscription fees to use any of these packages, whatsoever. The Witnet SDK is totally open sourced and distributed under MIT license.
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:
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 no otherwise specified, and no WITNET_RPC_PROVIDER is set in the environment, classes from the Javascript library will rely on https://rpc.witnet.io as default Wit/RPC provider.
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.
Smoke tests
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?