.validators

Provides methods to validators and validator related data.

Get a list of validators, optionally filtering by key_holder and contract_type

import { NorthstakeApi } from '@northstake/northstakeapi'
const api = new NorthstakeApi('apiKey', 'privateKey')

const {body:validators} = await api.validators.getValidators()

for (const validator of validators) {
    console.log(`
      Validator asset: ${validator.asset}
      Validator balance: ${validator.balance}
      Validator contract_address: ${validator.contract_address}
      Validator exit_estimate: ${validator.exit_estimate}
      Validator key_holder: ${validator.key_holder}
      Validator status: ${validator.status}
      Validator index: ${validator.validator_index}
      Validator public key: ${validator.validator_public_key }
      Validator type: ${validator.validator_type}
      `)
  }

Retrieves a paginated list of validator withdrawals. It supports filtering by start and end date, page number, and limit. Additionally, it allows filtering by validator indices.

import { NorthstakeApi } from '@northstake/northstakeapi'
const api = new NorthstakeApi('apiKey', 'privateKey')

// Optional query parameters
const params = {
  start_date: '2024-01-01',  // Optional: Filter by start date
  end_date: '2024-03-20',    // Optional: Filter by end date
  page: 1,                   // Optional: Default is 1
  limit: 10,                 // Optional: Default is 100
  validator_indices: '123,456,789'  // Optional: Comma-separated validator indices
}

const { body } = await api.validators.getValidatorWithdrawals(params)

console.log(`Total withdrawals: ${body.total}`)
console.log(`Current page: ${body.currentPage} of ${body.pages}`)
d
for (const withdrawal of body.withdrawals) {
  console.log(`
    Asset: ${withdrawal.asset}
    Validator Index: ${withdrawal.validator_index}
    Public Key: ${withdrawal.validator_public_key}
    Withdrawal Time: ${withdrawal.withdrawal_time}
    Withdrawal Address: ${withdrawal.withdrawal_address}
    Epoch: ${withdrawal.epoch}
    Slot: ${withdrawal.slot}
    Withdrawal Index: ${withdrawal.withdrawal_index}
    Amount: ${withdrawal.amount}
  `)
}