A P-Chain Client. PChainClient
Get the balance of AVAX controlled by a given address.
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"]
})
Get a block by its ID.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const block = await client.pChain.getBlock({
blockID: "d7WYmb8VeZNHsny3EJCwMm6QA37s1EHwMxw1Y71V3FqPZ5EFG",
encoding: "hex"
})
Get a block by its height.
Get all the blockchains that exist (excluding the P-Chain).
Get the status of a blockchain.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const status = await client.pChain.getBlockchainStatus({
blockchainID: "11111111111111111111111111111111LpoYY"
})
Get the current supply of an asset.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const supply = await client.pChain.getCurrentSupply({
assetID: "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z"
})
Get the current validators of the specified Subnet.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const validators = await client.pChain.getCurrentValidators({
subnetID: "11111111111111111111111111111111LpoYY"
})
Get the fee configuration for the P-Chain.
Get the current fee state of the P-Chain.
Get the height of the last accepted block.
Get the L1 validator information.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const validator = await client.pChain.getL1Validator({
nodeID: "NodeID-111111111111111111111111111111111111111"
})
Get the minimum stake amount for a subnet.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const minStake = await client.pChain.getMinStake({
subnetID: "11111111111111111111111111111111LpoYY"
})
Get the proposed height of the P-Chain.
Get the reward UTXOs for a transaction.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const rewardUTXOs = await client.pChain.getRewardUTXOs({
txID: "11111111111111111111111111111111LpoYY",
encoding: "hex"
})
Get the stake amount for a set of addresses.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const stake = await client.pChain.getStake({
addresses: ["P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"],
subnetID: "11111111111111111111111111111111LpoYY"
})
Get the staking asset ID for a subnet.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const stakingAssetID = await client.pChain.getStakingAssetID({
subnetID: "11111111111111111111111111111111LpoYY"
})
Get information about a subnet.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const subnet = await client.pChain.getSubnet({
subnetID: "11111111111111111111111111111111LpoYY"
})
Get all subnets.
Get the current timestamp of the P-Chain.
Get the total stake amount for a subnet.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const totalStake = await client.pChain.getTotalStake({
subnetID: "11111111111111111111111111111111LpoYY"
})
Get a transaction by its ID.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const tx = await client.pChain.getTx({
txID: "11111111111111111111111111111111LpoYY",
encoding: "hex"
})
Get the status of a transaction.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const status = await client.pChain.getTxStatus({
txID: "11111111111111111111111111111111LpoYY"
})
Get the UTXOs for a set of addresses.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const utxos = await client.pChain.getUTXOs({
addresses: ["P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"],
sourceChain: "X"
})
Get the validators at a specific height.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const validators = await client.pChain.getValidatorsAt({
height: 1000001,
subnetID: "11111111111111111111111111111111LpoYY"
})
Issue a transaction to the Platform Chain.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const txID = await client.pChain.issueTx({
tx: "0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730",
encoding: "hex"
})
Sample validators from the specified Subnet.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const validators = await client.pChain.sampleValidators({
size: 2,
subnetID: "11111111111111111111111111111111LpoYY"
})
Get the Subnet that validates a given blockchain.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const subnetID = await client.pChain.validatedBy({
blockchainID: "11111111111111111111111111111111LpoYY"
})
Get the IDs of the blockchains a Subnet validates.
import { createAvalancheClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createAvalancheClient({
chain: avalanche,
transport: {
type: "http",
},
})
const blockchainIDs = await client.pChain.validates({
subnetID: "11111111111111111111111111111111LpoYY"
})
import { createPChainClient} from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const client = createPChainClient({
chain: avalanche,
transport: {
type: "http",
},
})
// Get the current validators
const validators = await client.getCurrentValidators({})
// Get subnet information
const subnet = await client.getSubnet({ subnetID: 'subnet-id' })
Creates a P-Chain (Platform Chain) Client with a given transport configured for a Chain.
The P-Chain Client is an interface to interact with the Avalanche Platform Chain through JSON-RPC API methods. The Platform Chain is responsible for: