LogoLogo
WebsiteDiscordTelegramTwitter
  • 🏠Witnet Oracle Docs
  • Introduction
    • ❓What is Witnet?
      • ⚙️Oracle Architecture
      • 🪙The Witnet Coin (Wit)
      • 👛Wallets
      • 🤔Frequently Asked Questions
      • 😎Awesome Witnet
    • 🚀Quick Tutorials
      • 📈Price Feeds
      • 🎲Randomness
      • 🌐APIs and HTTP GET/POST
      • ⛏️Mining Wit
  • Smart contracts developers
    • ⛓️Supported chains
    • 🔮Wit/Oracle
      • HTTP GET Requests in Solidity
      • HTTP POST Requests in Solidity
      • Query GraphQL APIs in Solidity
      • Dynamic Requests in Solidity
      • UsingWitnet Inheritance
      • API Reference
        • Solidity API
          • Solidity Contracts
            • WitnetRequestBoard
        • Javascript API
        • RADON API
          • RADON Type System
          • RADON Errors
      • Multi-chain Addresses
    • 💹Wit/Price Feeds
      • How To Use Witnet Price Feeds
      • Update Conditions
      • Code Examples
      • API Reference
      • Multi-chain Addresses
        • Arbitrum Price Feeds
        • Avalanche Price Feeds
        • Base Price Feeds
        • Boba Price Feeds
        • Celo Price Feeds
        • Conflux Price Feeds
        • Cronos Price Feeds
        • Dogechain Price Feeds
        • Elastos Price Feeds
        • Ethereum Price Feeds
        • Gnosis Chain Price Feeds
        • Kaia Price Feeds
        • Kava Price Feeds
        • KCC Price Feeds
        • Mantle Price Feeds
        • Meter Price Feeds
        • Metis Price Feeds
        • Moonbeam Price Feeds
        • OKX Price Feeds
        • Optimism Price Feeds
        • Polygon Price Feeds
        • Reef Price Feeds
        • Scroll Price Feeds
        • Syscoin Price Feeds
        • Ultron Price Feeds
        • Request new price feed or chain support
    • 🎲Wit/Randomness
      • Generating Randomness
      • WitnetRandomness Contract
      • Low-level Requests
      • Code Examples
      • API Reference
      • Multi-chain Addresses
    • 🏗️Guides
      • 📖Solidity Contracts
        • Appliances
          • 📃WitnetPriceFeeds
          • 📃WitnetRandomness
        • Core
          • 📃WitnetOracle
          • 📃WitnetRadonRegistry
          • 📃WitnetRequest
          • 📃WitnetRequestFactory
          • 📃WitnetRequestTemplate
        • Mockups
          • 📃UsingWitnet
          • 📃UsingWitnetRandomness
          • 📃UsingWitnetRequest
          • 📃UsingWitnetRequestTemplate
          • 📃WitnetRandomnessRequestConsumer
          • 📃WitnetRequestConsumer
          • 📃WitnetRequestTemplateConsumer
      • 🧙Solidity Wizard
    • 🎓Tutorials
      • Building a Satoshi/Wei custom price feed
  • Witnet SDK
    • 👋Introduction
    • 🚀Getting Started
    • 🏗️How-to Guides
      • Connect to a Wit/RPC provider
      • Query stake entries in Witnet
      • Manage Witnet wallets
      • Manage Witnet UTXOs
      • Manage Witnet transactions
    • 🎓Tutorials
    • 📚Reference Material
      • 🔌APIs
        • Wit/Node JSON-RPC API
  • Witnet Validators
    • 💻Node Requirements
    • 🚀Getting Started (Docker)
    • 🔎Next steps
    • 🤓Advanced Setups
      • Run node as a systemd service
      • Run node with docker compose
      • Paranoid mode (Witnet over proxies and Tor)
      • Configuration file
    • ⌨️CLI Reference
  • 🗜️Compile from Source Code
Powered by GitBook
On this page
  • List currently active validators
  • List stake deposits withdrawable from some address
  • List stake deposits delegated into some validator address

Was this helpful?

Edit on GitHub
  1. Witnet SDK
  2. How-to Guides

Query stake entries in Witnet

Get full or filtered lists of stake entries in Witnet, using the Witnet SDK.

PreviousConnect to a Wit/RPC providerNextManage Witnet wallets

Last updated 28 days ago

Was this helpful?

The code examples below assume that the environment is properly set up as described in . You can easily adapt the examples to pass the URL of the Wit/RPC provider to use, and/or the wallet master key (and the password, if encrypted).

For a node being able to validate blocks and oracle queries (aka. data request transactions), it requires other identities (i.e. "stakers") to trust and delegate some $WIT coins into it. Whenever some additional $WIT coins are deposited into a validator address, the depositing identity decides the address with rights to eventually withdraw the deposited coins, plus accumulated earnings, minus some commission that the node will charge as compensation for its work and commitment. The "withdrawer" address needs not be the same as the "staker" address, not the "validator" address itself.

For every validator and withdrawer pair, the Witnet nodes keep track of a so-called "stake entry", where the current amount of withdrawable $WIT coins is stored, as well as the last time when a validator managed to validate a block (or participate in the resolution of an oracle query) based on such stake entry.

List currently active validators

Active validators in Witnet are considered to be those nodes having either included a valid block into the blockchain, or trustfully participated in the resolution of an oracle query during a past, but recent, number of epochs.

A new block gets validated every 20 seconds in the Witnet blockchain.

const { Witnet } = require('@witnet/sdk')
const provider = await Witnet.Provider.fromURL("https://rpc-testnet.witnet.io")

let since = -4320 // 4320 epochs x 20 secs ~ 24 hours ago
let stakes = await provider.stakes({ 
    params: { 
        distinct: true,
        orderBy: { by: Witnet.StakesOrderBy.Mining, desc: true },
        since,
    }
})
import Witnet from '@witnet/sdk'
const provider = await Witnet.Provider.fromURL("https://rpc-testnet.witnet.io")

let since: number = -4320 // 4320 epochs x 20 secs ~ 24 hours ago
let stakes: Array<Witnet.StakeEntry> = await provider.stakes({ 
    params: { 
        distinct: true,
        orderBy: { by: Witnet.StakesOrderBy.Mining, desc: true },
        since,
    }
})
$ npx witnet network senate --since 4320 --verbose

List stake deposits withdrawable from some address

const { Witnet } = require('@witnet/sdk')
const provider = await Witnet.Provider.fromEnv()

let stakes = await provider.stakes({ 
    filter: {
        withdrawer: "wit165ec489lcrt27w5wa7q9je7rgr4dtvyff9vwsc",
    },
    params: { 
        orderBy: { 
            by: Witnet.StakesOrderBy.Coins, 
            desc: true 
        },
    },
})
import Witnet from '@witnet/sdk'
const provider = await Witnet.Provider.fromEnv()

let stakes: Array<Witnet.StakeEntry> = await provider.stakes({ 
    filter: {
        withdrawer: "wit165ec489lcrt27w5wa7q9je7rgr4dtvyff9vwsc",
    },
    params: { 
        orderBy: { 
            by: Witnet.StakesOrderBy.Coins, 
            desc: true 
        },
    },
})
$ npx witnet network --withdrawer wit165ec489lcrt27w5wa7q9je7rgr4dtvyff9vwsc

List stake deposits delegated into some validator address

const { Witnet } = require('@witnet/sdk')
const provider = await Witnet.Provider.fromEnv()

let stakes = await provider.stakes({ 
    filter: {
        validator: "wit12x09p34zx0wpxaxknfdjnyxhcguv4jvkxerllz",
    },
    params: { 
        orderBy: { 
            by: Witnet.StakesOrderBy.Coins, 
            desc: true 
        },
    },
})
import Witnet from '@witnet/sdk'
const provider = await Witnet.Provider.fromEnv()

let stakes: Array<Witnet.StakeEntry> = await provider.stakes({ 
    filter: {
        validator: "wit12x09p34zx0wpxaxknfdjnyxhcguv4jvkxerllz",
    },
    params: { 
        orderBy: { by: Witnet.StakesOrderBy.Coins, desc: true },
    },
})
$ npx witnet network --validator wit165ec489lcrt27w5wa7q9je7rgr4dtvyff9vwsc
🏗️
Getting Started