Granite Upgrade Activates in06d:02h:04m:20s
MethodsPublic Methods

P-Chain Methods

Complete reference for P-Chain (Platform Chain) methods

Overview

The P-Chain (Platform Chain) is Avalanche's coordinating chain responsible for managing validators, delegators, subnets, and blockchains. This reference covers all read-only P-Chain operations available through the Avalanche Client SDK.

Balance Operations

getBalance

Get the balance of AVAX controlled by a given address.

Function Signature:

function getBalance(
  params: GetBalanceParameters
): Promise<GetBalanceReturnType>;

interface GetBalanceParameters {
  addresses: string[];
}

interface GetBalanceReturnType {
  balance: bigint;
  unlocked: bigint;
  lockedStakeable: bigint;
  lockedNotStakeable: bigint;
  utxoIDs: {
    txID: string;
    outputIndex: number;
  }[];
}

Parameters:

NameTypeRequiredDescription
addressesstring[]YesArray of P-Chain addresses to query

Returns:

TypeDescription
GetBalanceReturnTypeBalance information object

Return Object:

PropertyTypeDescription
balancebigintTotal balance
unlockedbigintUnlocked balance
lockedStakeablebigintLocked and stakeable balance
lockedNotStakeablebigintLocked but not stakeable balance
utxoIDsarrayArray of UTXO IDs referencing the addresses

Example:

import { createAvalancheClient } from "@avalanche-sdk/client";
import { avalanche } from "@avalanche-sdk/client/chains";

const client = createAvalancheClient({
  chain: avalanche,
  transport: { type: "http" },
});

const balance = await client.pChain.getBalance({
  addresses: ["P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"],
});

console.log("Total balance:", balance.balance);
console.log("Unlocked:", balance.unlocked);
console.log("Locked stakeable:", balance.lockedStakeable);

Related:


getUTXOs

Get the UTXOs (Unspent Transaction Outputs) controlled by a set of addresses.

Function Signature:

function getUTXOs(params: GetUTXOsParameters): Promise<GetUTXOsReturnType>;

interface GetUTXOsParameters {
  addresses: string[];
  sourceChain?: string;
  limit?: number;
  startIndex?: {
    address: string;
    utxo: string;
  };
  encoding?: "hex";
}

interface GetUTXOsReturnType {
  numFetched: number;
  utxos: string[];
  endIndex: {
    address: string;
    utxo: string;
  };
  sourceChain?: string;
  encoding: "hex";
}

Parameters:

NameTypeRequiredDescription
addressesstring[]YesArray of P-Chain addresses
sourceChainstringNoSource chain ID (e.g., "X" for X-Chain)
limitnumberNoMaximum number of UTXOs to return
startIndex{ address: string; utxo: string }NoPagination cursor for next page
encoding"hex"NoEncoding format (can only be "hex" if provided)

Returns:

TypeDescription
GetUTXOsReturnTypeUTXO data with pagination

Return Object:

PropertyTypeDescription
numFetchednumberNumber of UTXOs fetched in this response
utxosstring[]Array of UTXO bytes (hex encoded)
endIndex{ address: string; utxo: string }Pagination cursor for fetching next page
sourceChainstringSource chain ID (if specified)
encoding"hex"Encoding format used

Example:

// Get first page
const utxos = await client.pChain.getUTXOs({
  addresses: ["P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"],
  limit: 100,
});

console.log("Fetched UTXOs:", utxos.numFetched);
console.log("UTXOs:", utxos.utxos);

// Get next page if needed
if (utxos.endIndex) {
  const moreUTXOs = await client.pChain.getUTXOs({
    addresses: ["P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"],
    startIndex: utxos.endIndex,
    limit: 100,
  });
}

Related:


Validator Operations

getCurrentValidators

Get the current validators of the specified Subnet.

Function Signature:

function getCurrentValidators(
  params: GetCurrentValidatorsParameters
): Promise<GetCurrentValidatorsReturnType>;

interface GetCurrentValidatorsParameters {
  subnetID?: string | Buffer;
  nodeIDs?: string[];
}

interface GetCurrentValidatorsReturnType {
  validators: Array<{
    accruedDelegateeReward: string;
    txID: string;
    startTime: string;
    endTime?: string;
    stakeAmount: string;
    nodeID: string;
    weight: string;
    validationRewardOwner?: {
      locktime: string;
      threshold: string;
      addresses: string[];
    };
    delegationRewardOwner?: {
      locktime: string;
      threshold: string;
      addresses: string[];
    };
    signer?: {
      publicKey: string;
      proofOfPosession: string;
    };
    delegatorCount?: string;
    delegatorWeight?: string;
    potentialReward?: string;
    delegationFee?: string;
    uptime?: string;
    connected?: boolean;
    delegators?: Array<{
      txID: string;
      startTime: string;
      endTime: string;
      stakeAmount: string;
      nodeID: string;
      rewardOwner: {
        locktime: string;
        threshold: string;
        addresses: string[];
      };
      potentialReward: string;
    }>;
  }>;
}

Parameters:

NameTypeRequiredDescription
subnetIDstring | BufferNoSubnet ID (defaults to Primary Network)
nodeIDsstring[]NoSpecific NodeIDs to query

Returns:

TypeDescription
GetCurrentValidatorsReturnTypeValidators list object

Return Object:

PropertyTypeDescription
validatorsarrayList of validators for the specified Subnet

Note: Many fields in the validator object are omitted if subnetID is not the Primary Network. The delegators field is only included when nodeIDs specifies a single NodeID.

Example:

// Get all validators on Primary Network
const validators = await client.pChain.getCurrentValidators({});

console.log("Total validators:", validators.validators.length);

// Get validators for specific subnet
const subnetValidators = await client.pChain.getCurrentValidators({
  subnetID: "11111111111111111111111111111111LpoYY",
});

// Get specific validators
const specificValidators = await client.pChain.getCurrentValidators({
  subnetID: "11111111111111111111111111111111LpoYY",
  nodeIDs: ["NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg"],
});

Related:


getValidatorsAt

Get the validators at a specific height.

Function Signature:

function getValidatorsAt(
  params: GetValidatorsAtParameters
): Promise<GetValidatorsAtReturnType>;

interface GetValidatorsAtParameters {
  height: number;
  subnetID?: string;
}

interface GetValidatorsAtReturnType {
  validators: Record<string, number>;
}

Parameters:

NameTypeRequiredDescription
heightnumberYesBlock height to query
subnetIDstringNoSubnet ID (defaults to Primary Network)

Returns:

TypeDescription
GetValidatorsAtReturnTypeValidators map object

Return Object:

PropertyTypeDescription
validatorsRecord<string, number>Map of validator IDs to their stake amounts

Example:

const validators = await client.pChain.getValidatorsAt({
  height: 1000001,
  subnetID: "11111111111111111111111111111111LpoYY",
});

console.log("Validators at height:", validators.validators);

Links:


getAllValidatorsAt

Get all validators at a specific height across all Subnets and the Primary Network.

Function Signature:

function getAllValidatorsAt(
  params: GetAllValidatorsAtParameters
): Promise<GetAllValidatorsAtReturnType>;

interface GetAllValidatorsAtParameters {
  height: number | "proposed";
}

interface GetAllValidatorsAtReturnType {
  validatorSets: Record<
    string,
    {
      validators: Array<{
        publicKey: string;
        weight: string;
        nodeIDs: string[];
      }>;
      totalWeight: string;
    }
  >;
}

Parameters:

NameTypeRequiredDescription
heightnumber | "proposed"YesP-Chain height or "proposed" for proposervm height

Returns:

TypeDescription
GetAllValidatorsAtReturnTypeValidator sets object

Return Object:

PropertyTypeDescription
validatorSetsobjectMap of Subnet IDs to their validator information

Note: The public API (api.avax.network) only supports height within 1000 blocks from the P-Chain tip.

Example:

// Get all validators at specific height
const validators = await client.pChain.getAllValidatorsAt({
  height: 1000001,
});

// Get validators at proposed height
const proposedValidators = await client.pChain.getAllValidatorsAt({
  height: "proposed",
});

console.log("Subnet IDs:", Object.keys(validators.validatorSets));
Object.entries(validators.validatorSets).forEach(([subnetID, set]) => {
  console.log(`Subnet ${subnetID}:`);
  console.log(`  Total weight: ${set.totalWeight}`);
  console.log(`  Validators: ${set.validators.length}`);
});

Related:


sampleValidators

Sample validators from the specified Subnet.

Function Signature:

function sampleValidators(
  params: SampleValidatorsParameters
): Promise<SampleValidatorsReturnType>;

interface SampleValidatorsParameters {
  samplingSize: number;
  subnetID?: string;
  pChainHeight?: number;
}

interface SampleValidatorsReturnType {
  validators: string[];
}

Parameters:

NameTypeRequiredDescription
samplingSizenumberYesNumber of validators to sample
subnetIDstringNoSubnet ID (defaults to Primary Network)
pChainHeightnumberNoBlock height (defaults to current)

Returns:

TypeDescription
SampleValidatorsReturnTypeSampled validators object

Return Object:

PropertyTypeDescription
validatorsstring[]Array of sampled validator NodeIDs

Example:

const sampled = await client.pChain.sampleValidators({
  samplingSize: 5,
  subnetID: "11111111111111111111111111111111LpoYY",
});

console.log("Sampled validators:", sampled.validators);

Related:


Block Operations

getHeight

Get the height of the last accepted block.

Function Signature:

function getHeight(): Promise<GetHeightReturnType>;

interface GetHeightReturnType {
  height: number;
}

Parameters:

No parameters required.

Returns:

TypeDescription
GetHeightReturnTypeHeight object

Return Object:

PropertyTypeDescription
heightnumberCurrent P-Chain block height

Example:

const height = await client.pChain.getHeight();
console.log("Current P-Chain height:", height.height);

Related:


getBlockByHeight

Get a block by its height.

Function Signature:

function getBlockByHeight(
  params: GetBlockByHeightParameters
): Promise<GetBlockByHeightReturnType>;

interface GetBlockByHeightParameters {
  height: number;
  encoding?: "hex" | "json";
}

interface GetBlockByHeightReturnType {
  encoding: "hex" | "json";
  block: string | object;
}

Parameters:

NameTypeRequiredDescription
heightnumberYesBlock height
encoding"hex" | "json"NoEncoding format (defaults to "hex")

Returns:

TypeDescription
GetBlockByHeightReturnTypeBlock data object

Return Object:

PropertyTypeDescription
encoding"hex" | "json"Encoding format used
blockstring | objectBlock data in the specified encoding format

Example:

const block = await client.pChain.getBlockByHeight({
  height: 12345,
  encoding: "hex",
});

console.log("Block data:", block.block);

Related:


getBlock

Get a block by its ID.

Function Signature:

function getBlock(params: GetBlockParameters): Promise<GetBlockReturnType>;

interface GetBlockParameters {
  blockId: string;
  encoding?: "hex" | "json";
}

interface GetBlockReturnType {
  encoding: "hex" | "json";
  block: string | object;
}

Parameters:

NameTypeRequiredDescription
blockIdstringYesBlock ID in CB58 format
encoding"hex" | "json"NoEncoding format (defaults to "hex")

Returns:

TypeDescription
GetBlockReturnTypeBlock data object

Return Object:

PropertyTypeDescription
encoding"hex" | "json"Encoding format used
blockstring | objectBlock data in the specified encoding format

Example:

const block = await client.pChain.getBlock({
  blockId: "d7WYmb8VeZNHsny3EJCwMm6QA37s1EHwMxw1Y71V3FqPZ5EFG",
  encoding: "hex",
});

console.log("Block:", block.block);

Related:


Staking Operations

getStake

Get the stake amount for a set of addresses.

Function Signature:

function getStake(params: GetStakeParameters): Promise<GetStakeReturnType>;

interface GetStakeParameters {
  addresses: string[];
  subnetID: string;
}

interface GetStakeReturnType {
  stakeAmount: bigint;
}

Parameters:

NameTypeRequiredDescription
addressesstring[]YesP-Chain addresses
subnetIDstringYesSubnet ID

Returns:

TypeDescription
GetStakeReturnTypeStake amount object

Return Object:

PropertyTypeDescription
stakeAmountbigintTotal stake amount for the addresses

Example:

const stake = await client.pChain.getStake({
  addresses: ["P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"],
  subnetID: "11111111111111111111111111111111LpoYY",
});

console.log("Stake amount:", stake.stakeAmount);

Related:


getTotalStake

Get the total amount of stake for a Subnet.

Function Signature:

function getTotalStake(
  params: GetTotalStakeParameters
): Promise<GetTotalStakeReturnType>;

interface GetTotalStakeParameters {
  subnetID: string;
}

interface GetTotalStakeReturnType {
  stake: bigint;
  weight: bigint;
}

Parameters:

NameTypeRequiredDescription
subnetIDstringYesSubnet ID

Returns:

TypeDescription
GetTotalStakeReturnTypeTotal stake object

Return Object:

PropertyTypeDescription
stakebigintTotal stake amount for the subnet
weightbigintTotal weight for the subnet

Example:

const totalStake = await client.pChain.getTotalStake({
  subnetID: "11111111111111111111111111111111LpoYY",
});

console.log("Total stake:", totalStake.stake);
console.log("Total weight:", totalStake.weight);

Related:


getMinStake

Get the minimum stake required to validate or delegate.

Function Signature:

function getMinStake(
  params: GetMinStakeParameters
): Promise<GetMinStakeReturnType>;

interface GetMinStakeParameters {
  subnetID: string;
}

interface GetMinStakeReturnType {
  minValidatorStake: bigint;
  minDelegatorStake: bigint;
}

Parameters:

NameTypeRequiredDescription
subnetIDstringYesSubnet ID

Returns:

TypeDescription
GetMinStakeReturnTypeMinimum stake object

Return Object:

PropertyTypeDescription
minValidatorStakebigintMinimum stake required to become a validator
minDelegatorStakebigintMinimum stake required to delegate

Example:

const minStake = await client.pChain.getMinStake({
  subnetID: "11111111111111111111111111111111LpoYY",
});

console.log("Min validator stake:", minStake.minValidatorStake);
console.log("Min delegator stake:", minStake.minDelegatorStake);

Related:


Subnet Operations

getSubnet

Get information about a subnet.

Function Signature:

function getSubnet(params: GetSubnetParameters): Promise<GetSubnetReturnType>;

interface GetSubnetParameters {
  subnetID: string;
}

interface GetSubnetReturnType {
  isPermissioned: boolean;
  controlKeys: string[];
  threshold: string;
  locktime: string;
  subnetTransformationTxID: string;
  conversionID: string;
  managerChainID: string;
  managerAddress: string | null;
}

Parameters:

NameTypeRequiredDescription
subnetIDstringYesThe ID of the subnet

Returns:

TypeDescription
GetSubnetReturnTypeSubnet information object

Return Object:

PropertyTypeDescription
isPermissionedbooleanWhether the subnet is permissioned
controlKeysstring[]Control keys for the subnet
thresholdstringSignature threshold
locktimestringLocktime for the subnet
subnetTransformationTxIDstringSubnet transformation transaction ID
conversionIDstringConversion ID
managerChainIDstringManager chain ID
managerAddressstring | nullManager address (null if not set)

Example:

const subnet = await client.pChain.getSubnet({
  subnetID: "11111111111111111111111111111111LpoYY",
});

console.log("Is permissioned:", subnet.isPermissioned);
console.log("Control keys:", subnet.controlKeys);
console.log("Threshold:", subnet.threshold);

Related:


getSubnets

Get information about multiple subnets.

Function Signature:

function getSubnets(
  params: GetSubnetsParameters
): Promise<GetSubnetsReturnType>;

interface GetSubnetsParameters {
  ids: string[];
}

interface GetSubnetsReturnType {
  subnets: {
    id: string;
    controlKeys: string[];
    threshold: string;
  }[];
}

Parameters:

NameTypeRequiredDescription
idsstring[]YesArray of subnet IDs to query

Returns:

TypeDescription
GetSubnetsReturnTypeSubnets information object

Return Object:

PropertyTypeDescription
subnetsarrayArray of subnet information objects

Example:

const subnets = await client.pChain.getSubnets({
  ids: [
    "11111111111111111111111111111111LpoYY",
    "SubnetID-11111111111111111111111111111111LpoYY",
  ],
});

console.log("Number of subnets:", subnets.subnets.length);
subnets.subnets.forEach((subnet) => {
  console.log("Subnet ID:", subnet.id);
  console.log("Control keys:", subnet.controlKeys);
});

Related:


getStakingAssetID

Get the staking asset ID for a subnet.

Function Signature:

function getStakingAssetID(
  params: GetStakingAssetIDParameters
): Promise<GetStakingAssetIDReturnType>;

interface GetStakingAssetIDParameters {
  subnetID: string;
}

interface GetStakingAssetIDReturnType {
  assetID: string;
}

Parameters:

NameTypeRequiredDescription
subnetIDstringYesThe ID of the subnet

Returns:

TypeDescription
GetStakingAssetIDReturnTypeStaking asset ID object

Return Object:

PropertyTypeDescription
assetIDstringAsset ID used for staking on the subnet

Example:

const stakingAsset = await client.pChain.getStakingAssetID({
  subnetID: "11111111111111111111111111111111LpoYY",
});

console.log("Staking asset ID:", stakingAsset.assetID);

Related:


Blockchain Operations

getBlockchains

Get all the blockchains that exist (excluding the P-Chain).

Function Signature:

function getBlockchains(): Promise<GetBlockchainsReturnType>;

interface GetBlockchainsReturnType {
  blockchains: {
    id: string;
    name: string;
    subnetID: string;
    vmID: string;
  }[];
}

Parameters:

No parameters required.

Returns:

TypeDescription
GetBlockchainsReturnTypeBlockchains list object

Return Object:

PropertyTypeDescription
blockchainsarrayArray of blockchain information objects

Example:

const blockchains = await client.pChain.getBlockchains();

console.log("Number of blockchains:", blockchains.blockchains.length);

blockchains.blockchains.forEach((blockchain) => {
  console.log("Blockchain:", blockchain.name);
  console.log("  ID:", blockchain.id);
  console.log("  Subnet ID:", blockchain.subnetID);
  console.log("  VM ID:", blockchain.vmID);
});

Related:


getBlockchainStatus

Get the status of a blockchain.

Function Signature:

function getBlockchainStatus(
  params: GetBlockchainStatusParameters
): Promise<GetBlockchainStatusReturnType>;

interface GetBlockchainStatusParameters {
  blockchainId: string;
}

interface GetBlockchainStatusReturnType {
  status: "Validating" | "Created" | "Preferred" | "Syncing" | "Unknown";
}

Parameters:

NameTypeRequiredDescription
blockchainIdstringYesThe ID of the blockchain

Returns:

TypeDescription
GetBlockchainStatusReturnTypeBlockchain status object

Return Object:

PropertyTypeDescription
statusstringBlockchain status: "Validating", "Created", "Preferred", "Syncing", or "Unknown"

Status Values:

  • Validating: The blockchain is being validated by this node
  • Created: The blockchain exists but isn't being validated by this node
  • Preferred: The blockchain was proposed to be created and is likely to be created, but the transaction isn't yet accepted
  • Syncing: This node is participating in the blockchain as a non-validating node
  • Unknown: The blockchain either wasn't proposed or the proposal isn't preferred

Example:

const status = await client.pChain.getBlockchainStatus({
  blockchainId: "11111111111111111111111111111111LpoYY",
});

console.log("Blockchain status:", status.status);

Related:


Transaction Operations

getTx

Get a transaction by its ID.

Function Signature:

function getTx(params: GetTxParameters): Promise<GetTxReturnType>;

interface GetTxParameters {
  txID: string;
  encoding?: "hex" | "json";
}

interface GetTxReturnType {
  encoding: "hex" | "json";
  tx: string | object;
}

Parameters:

NameTypeRequiredDescription
txIDstringYesTransaction ID in CB58 format
encoding"hex" | "json"NoEncoding format (defaults to "hex")

Returns:

TypeDescription
GetTxReturnTypeTransaction data object

Return Object:

PropertyTypeDescription
encoding"hex" | "json"Encoding format used
txstring | objectTransaction data in the specified encoding format

Example:

const tx = await client.pChain.getTx({
  txID: "11111111111111111111111111111111LpoYY",
  encoding: "hex",
});

console.log("Transaction:", tx);

Related:


getTxStatus

Get the status of a transaction.

Function Signature:

function getTxStatus(
  params: GetTxStatusParameters
): Promise<GetTxStatusReturnType>;

interface GetTxStatusParameters {
  txID: string;
}

interface GetTxStatusReturnType {
  status: "Committed" | "Pending" | "Dropped" | "Unknown";
  reason?: string;
}

Parameters:

NameTypeRequiredDescription
txIDstringYesTransaction ID in CB58 format

Returns:

TypeDescription
GetTxStatusReturnTypeTransaction status object

Return Object:

PropertyTypeDescription
statusstringTransaction status: "Committed", "Pending", "Dropped", or "Unknown"
reasonstringOptional reason for the status (if dropped)

Status Values:

  • Committed: The transaction is (or will be) accepted by every node
  • Pending: The transaction is being voted on by this node
  • Dropped: The transaction will never be accepted by any node in the network
  • Unknown: The transaction hasn't been seen by this node

Example:

const txStatus = await client.pChain.getTxStatus({
  txID: "11111111111111111111111111111111LpoYY",
});

console.log("Transaction status:", txStatus.status);
if (txStatus.reason) {
  console.log("Reason:", txStatus.reason);
}

Related:


issueTx

Issue a transaction to the Platform Chain.

Function Signature:

function issueTx(params: IssueTxParameters): Promise<IssueTxReturnType>;

interface IssueTxParameters {
  tx: string;
  encoding: "hex";
}

interface IssueTxReturnType {
  txID: string;
}

Parameters:

NameTypeRequiredDescription
txstringYesTransaction bytes in hex format
encoding"hex"YesEncoding format (must be "hex")

Returns:

TypeDescription
IssueTxReturnTypeTransaction ID object

Return Object:

PropertyTypeDescription
txIDstringTransaction ID in CB58 format

Example:

const txID = await client.pChain.issueTx({
  tx: "0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0...",
  encoding: "hex",
});

console.log("Transaction issued:", txID.txID);

Related:


Block Operations

getProposedHeight

Get the proposed height of the P-Chain.

Function Signature:

function getProposedHeight(): Promise<GetProposedHeightReturnType>;

interface GetProposedHeightReturnType {
  height: number;
}

Parameters:

No parameters required.

Returns:

TypeDescription
GetProposedHeightReturnTypeProposed height object

Return Object:

PropertyTypeDescription
heightnumberProposed P-Chain block height

Example:

const proposedHeight = await client.pChain.getProposedHeight();
console.log("Proposed height:", proposedHeight.height);

Related:


getTimestamp

Get the current timestamp of the P-Chain.

Function Signature:

function getTimestamp(): Promise<GetTimestampReturnType>;

interface GetTimestampReturnType {
  timestamp: string;
}

Parameters:

No parameters required.

Returns:

TypeDescription
GetTimestampReturnTypeTimestamp object

Return Object:

PropertyTypeDescription
timestampstringCurrent timestamp in ISO 8601 format

Example:

const timestamp = await client.pChain.getTimestamp();
console.log("Current timestamp:", timestamp.timestamp);

Related:


Fee Operations

getFeeConfig

Get the fee configuration for the P-Chain.

Function Signature:

function getFeeConfig(): Promise<GetFeeConfigReturnType>;

interface GetFeeConfigReturnType {
  weights: [
    bandwidth: number,
    dbRead: number,
    dbWrite: number,
    compute: number,
  ];
  maxCapacity: bigint;
  maxPerSecond: bigint;
  targetPerSecond: bigint;
  minPrice: bigint;
  excessConversionConstant: bigint;
}

Parameters:

No parameters required.

Returns:

TypeDescription
GetFeeConfigReturnTypeFee configuration object

Return Object:

PropertyTypeDescription
weightsarrayFee weights: [bandwidth, dbRead, dbWrite, compute]
maxCapacitybigintMaximum capacity
maxPerSecondbigintMaximum per second
targetPerSecondbigintTarget per second
minPricebigintMinimum price
excessConversionConstantbigintExcess conversion constant

Example:

const feeConfig = await client.pChain.getFeeConfig();

console.log("Fee weights:", feeConfig.weights);
console.log("Max capacity:", feeConfig.maxCapacity);
console.log("Target per second:", feeConfig.targetPerSecond);
console.log("Min price:", feeConfig.minPrice);

Related:


getFeeState

Get the current fee state of the P-Chain.

Function Signature:

function getFeeState(): Promise<GetFeeStateReturnType>;

interface GetFeeStateReturnType {
  capacity: bigint;
  excess: bigint;
  price: bigint;
  timestamp: string;
}

Parameters:

No parameters required.

Returns:

TypeDescription
GetFeeStateReturnTypeFee state object

Return Object:

PropertyTypeDescription
capacitybigintCurrent fee capacity
excessbigintCurrent fee excess
pricebigintCurrent fee price
timestampstringTimestamp of the fee state

Example:

const feeState = await client.pChain.getFeeState();

console.log("Fee capacity:", feeState.capacity);
console.log("Fee excess:", feeState.excess);
console.log("Fee price:", feeState.price);
console.log("Timestamp:", feeState.timestamp);

Related:


Supply Operations

getCurrentSupply

Get the current supply of AVAX tokens.

Function Signature:

function getCurrentSupply(
  params?: GetCurrentSupplyParameters
): Promise<GetCurrentSupplyReturnType>;

interface GetCurrentSupplyParameters {
  subnetId?: string;
}

interface GetCurrentSupplyReturnType {
  supply: bigint;
}

Parameters:

NameTypeRequiredDescription
subnetIdstringNoSubnet ID (defaults to Primary Network if omitted)

Returns:

TypeDescription
GetCurrentSupplyReturnTypeSupply object

Return Object:

PropertyTypeDescription
supplybigintUpper bound on the number of tokens that exist

Example:

// Get Primary Network supply
const supply = await client.pChain.getCurrentSupply();
console.log("Primary Network supply:", supply.supply);

// Get subnet-specific supply
const subnetSupply = await client.pChain.getCurrentSupply({
  subnetId: "11111111111111111111111111111111LpoYY",
});
console.log("Subnet supply:", subnetSupply.supply);

Related:


Reward Operations

getRewardUTXOs

Get the reward UTXOs for a transaction.

Function Signature:

function getRewardUTXOs(
  params: GetRewardUTXOsParameters
): Promise<GetRewardUTXOsReturnType>;

interface GetRewardUTXOsParameters {
  txID: string;
  encoding?: "hex";
}

interface GetRewardUTXOsReturnType {
  numFetched: number;
  utxos: string[];
  encoding: "hex";
}

Parameters:

NameTypeRequiredDescription
txIDstringYesTransaction ID in CB58 format
encoding"hex"NoEncoding format (defaults to "hex")

Returns:

TypeDescription
GetRewardUTXOsReturnTypeReward UTXOs object

Return Object:

PropertyTypeDescription
numFetchednumberNumber of reward UTXOs fetched
utxosstring[]Array of reward UTXO bytes (hex encoded)
encoding"hex"Encoding format used

Example:

const rewardUTXOs = await client.pChain.getRewardUTXOs({
  txID: "11111111111111111111111111111111LpoYY",
  encoding: "hex",
});

console.log("Reward UTXOs fetched:", rewardUTXOs.numFetched);
console.log("UTXOs:", rewardUTXOs.utxos);

Related:


L1 Validator Operations

getL1Validator

Get information about an L1 validator.

Function Signature:

function getL1Validator(
  params: GetL1ValidatorParameters
): Promise<GetL1ValidatorReturnType>;

interface GetL1ValidatorParameters {
  validationID: string;
}

interface GetL1ValidatorReturnType {
  subnetID: string;
  nodeID: string;
  publicKey: string;
  remainingBalanceOwner: {
    addresses: string[];
    locktime: string;
    threshold: string;
  };
  deactivationOwner: {
    addresses: string[];
    locktime: string;
    threshold: string;
  };
  startTime: bigint;
  weight: bigint;
  minNonce?: bigint;
  balance?: bigint;
  height?: bigint;
}

Parameters:

NameTypeRequiredDescription
validationIDstringYesThe ID for L1 subnet validator registration transaction

Returns:

TypeDescription
GetL1ValidatorReturnTypeL1 validator information object

Return Object:

PropertyTypeDescription
subnetIDstringL1 subnet ID this validator is validating
nodeIDstringNode ID of the validator
publicKeystringCompressed BLS public key of the validator
remainingBalanceOwnerobjectOwner that will receive any withdrawn balance
deactivationOwnerobjectOwner that can withdraw the balance
startTimebigintUnix timestamp when validator was added
weightbigintWeight used for consensus voting and ICM
minNoncebigintMinimum nonce for SetL1ValidatorWeightTx
balancebigintCurrent remaining balance for continuous fee
heightbigintHeight of the last accepted block

Example:

const validator = await client.pChain.getL1Validator({
  validationID: "11111111111111111111111111111111LpoYY",
});

console.log("Subnet ID:", validator.subnetID);
console.log("Node ID:", validator.nodeID);
console.log("Weight:", validator.weight);
console.log("Start time:", validator.startTime);

Related:


Chain Validation

validatedBy

Get the subnet that validates a given blockchain.

Function Signature:

function validatedBy(
  params: ValidatedByParameters
): Promise<ValidatedByReturnType>;

interface ValidatedByParameters {
  blockchainID: string;
}

interface ValidatedByReturnType {
  subnetID: string;
}

Parameters:

NameTypeRequiredDescription
blockchainIDstringYesThe blockchain's ID

Returns:

TypeDescription
ValidatedByReturnTypeSubnet ID object

Return Object:

PropertyTypeDescription
subnetIDstringID of the subnet that validates the blockchain

Example:

const validatedBy = await client.pChain.validatedBy({
  blockchainID: "11111111111111111111111111111111LpoYY",
});

console.log("Validated by subnet:", validatedBy.subnetID);

Related:


validates

Get the IDs of the blockchains a subnet validates.

Function Signature:

function validates(params: ValidatesParameters): Promise<ValidatesReturnType>;

interface ValidatesParameters {
  subnetID: string;
}

interface ValidatesReturnType {
  blockchainIDs: string[];
}

Parameters:

NameTypeRequiredDescription
subnetIDstringYesThe subnet's ID

Returns:

TypeDescription
ValidatesReturnTypeBlockchain IDs object

Return Object:

PropertyTypeDescription
blockchainIDsstring[]Array of blockchain IDs validated by the subnet

Example:

const validates = await client.pChain.validates({
  subnetID: "11111111111111111111111111111111LpoYY",
});

console.log("Number of blockchains:", validates.blockchainIDs.length);
validates.blockchainIDs.forEach((blockchainID) => {
  console.log("Blockchain ID:", blockchainID);
});

Related:

Next Steps

Is this guide helpful?