Skip to content
On this page

Getting Info Polygon

The get namespace contains methods used for getting info. The unique methods to the get namespace are:

  • getReward(address): Gets the user's reward balance in tokens.
  • getTotalDelegate(address): Gets the user's delegate balance in tokens.
  • getUnbond(address): Gets the user's unbond balance in tokens.
  • getCurrentEpoch(): Gets current epoch.
  • getBalanceOf(address, isPOL = false): Gets the user's balance
  • getUnbondNonces(address): Gets unbound nonce by address

Getting Info Code Example

ts
// Import SDK
import { Polygon } from '@everstake/wallet-sdk';

// User wallet address.
const address = '0x4D3F0BF20Dd5DA8C6800c5cA17d721131E366651';

// Gets the user's reward balance in tokens.
const getReward = await Polygon.getReward(address);
console.log(getReward); // BigNumber(3.34) (MATIC)

// Gets the user's delegate balance in tokens.
const getTotalDelegate = await Polygon.getTotalDelegate(address);
console.log(getTotalDelegate); // BigNumber(20.5) (MATIC)

// Gets the user's unbond balance in tokens.
const getUnbond = await Polygon.getUnbond(address);
console.log(getUnbond); // BigNumber(2.2) (MATIC)

// Gets current epoch.
const epoch = await Polygon.getCurrentEpoch();
console.log(epoch); // 999

// Gets current balance.
const balance = await Polygon.getBalanceOf(address, false);
console.log(balance); // BigNuber(100.2) (MATIC)

// Gets unbound nonce.
const nonce = await Polygon.getUnbondNonces(address);
console.log(nonce); // "5"