Validators
For more inspiration, check out these recipes involving managed users
๐ฅRegister new managed userOpen Recipe
Get all validators associated with the managed user
import { NorthstakeApi } from '@northstake/northstakeapi'
const api = new NorthstakeApi('apiKey', 'privateKey')
const {body:validators} = await api.managedUsersValidators.getValidatorsForUser('1234')
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 for a specific managed user. 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 = {
userId: '1234', //required
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.managedUsersValidators.getValidatorWithdrawalsForUser(params)
console.log(`Total withdrawals: ${body.total}`)
console.log(`Current page: ${body.currentPage} of ${body.pages}`)
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}
`)
}
Updated about 2 months ago