Avalanche — EVM methods, P-Chain methods
API reference for Avalanche. All methods ->
eth_getAssetBalance
Retrieves the balance of first class Avalanche Native Tokens on the C-Chain.
In addition to the standard Ethereum APIs, Avalanche offers eth_getAssetBalance to retrieve the balance of first class Avalanche Native Tokens on the C-Chain (excluding AVAX, which must be fetched with eth_getBalance).
Parameters
Signature:
eth_getAssetBalance({
address: string,
blk: BlkNrOrHash,
assetID: string,
}) -> {balance: int}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):address: owner of the asset.blk: the block number or hash at which to retrieve the balance.assetID: an ID of the asset for which the balance is requested.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"eth_getAssetBalance",
"params" : [
"0x8723e5773847A4Eb5FeEDabD9320802c5c812F46",
"latest",
"3RvKBAmQnfYionFXMfW5P8TDZgZiogKbHjM8cjpu16LKAgF5T"
]
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1388"
}
eth_baseFee
Retrieves the base fee for the next block.
Parameters
Signature:
eth_baseFee() -> {}
Request parameters:
id(integer; required): a request ID (example: 1).jsonrpc(string; required): a JSON RPC spec used (example: 2.0).method(string; required): a method used for the request.params(array; required): none.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"eth_baseFee",
"params" : []
}'
Request example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x34630b8a00"
}
eth_maxPriorityFeePerGas
Retrieves the priority fee needed to be included in a block.
Parameters
Signature:
eth_maxPriorityFeePerGas() -> {}
Request parameters:
id(integer; required): a request ID (example: 1).jsonrpc(string; required): a JSON RPC spec used (example: 2.0).method(string; required): a method used for the request.params(array; required): none.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"eth_maxPriorityFeePerGas",
"params" : []
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x2540be400"
}
eth_getChainConfig
Retrieves chain config.
Parameters
Signature:
eth_getChainConfig({}) -> {chainConfig: json}
Request parameters:
id(integer; required): a request ID (example: 1).jsonrpc(string; required): a JSON RPC spec used (example: 2.0).method(string; required): a method used for the request.params(array; required): none.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"eth_getChainConfig",
"params" : []
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"chainId": 43112,
"homesteadBlock": 0,
"daoForkBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"apricotPhase1BlockTimestamp": 0,
"apricotPhase2BlockTimestamp": 0,
"apricotPhase3BlockTimestamp": 0,
"apricotPhase4BlockTimestamp": 0,
"apricotPhase5BlockTimestamp": 0
}
}
P-Chain methods
platform.getBalance— retrieves the balance of AVAX for a given address.platform.getBlock— retrieves a block by its ID.platform.getBlockchains— retrieves all the blockchains that exist (excluding the P-Chain).platform.getBlockchainStatus— retrieves the status of a blockchain.platform.getCurrentSupply— retrieves an upper bound on the amount of existing tokens that can stake the requested Subnet.platform.getCurrentValidators— retrieves the list of current validators of the given Subnet.platform.getHeight— retrieves the height of the latest accepted block.platform.getMaxStakeAmount— retrieves the maximum amount of nAVAX staking to the named node during a particular time period.platform.getMinStake— retrieves the minimum amount of tokens required to validate the requested Subnet and the minimum amount of tokens that can be delegated.platform.getPendingValidators— retrieves the list of validators in the pending validator set of the specified Subnet.platform.getRewardUTXOs— retrieves the UTXOs rewarded after the provided transaction's staking or delegation period has ended.platform.getStake— retrieves the amount of nAVAX staked by a set of addresses.platform.getStakingAssetID— retrieves an assetID for a Subnet’s staking asset.platform.getSubnets— retrieves info about the Subnets.platform.getTimestamp— retrieves the current P-Chain timestamp.platform.getTotalStake— retrieves the total amount of tokens staked on the requested Subnet.platform.getTx— retrieves a transaction by its ID.platform.getTxStatus— retrieves a transaction’s status by its ID.platform.getUTXOs— retrieves the UTXOs that reference a given set of addresses.platform.getValidatorsAt— retrieves the validators and their weights of a Subnet or the Primary Network at a given P-Chain height.platform.issueTx— issues a transaction to the Platform Chain.platform.listAddresses— retrieves the list of addresses controlled by the given user.platform.sampleValidators— retrieves the validators from the specified Subnet.platform.validatedBy— retrieves the Subnet that validates a given blockchain.platform.validates— retrieves the IDs of the blockchains a Subnet validates.
platform.getBalance
Retrieves the balance of AVAX for a given address.
Parameters
Signature:
platform.getBalance({
addresses: []string
}) -> {
balances: string -> int,
unlockeds: string -> int,
lockedStakeables: string -> int,
lockedNotStakeables: string -> int,
utxoIDs: []{
txID: string,
outputIndex: int
}
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):addresses: the addresses to get the balance for.
Response parameters:
balances: a map from assetID to the total balance.unlockeds: a map from assetID to the unlocked balance.lockedStakeables: a map from assetID to the locked stakeable balance.lockedNotStakeables: a map from assetID to the locked and not stakeable balance.utxoIDs: the IDs of the UTXOs that referenceaddress.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getBalance",
"params" :{
"address":"P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"balance": "30000000000000000",
"unlocked": "20000000000000000",
"lockedStakeable": "10000000000000000",
"lockedNotStakeable": "0",
"balances": {
"BUuypiq2wyuLMvyhzFXcPyxPMCgSp7eeDohhQRqTChoBjKziC": "30000000000000000"
},
"unlockeds": {
"BUuypiq2wyuLMvyhzFXcPyxPMCgSp7eeDohhQRqTChoBjKziC": "20000000000000000"
},
"lockedStakeables": {
"BUuypiq2wyuLMvyhzFXcPyxPMCgSp7eeDohhQRqTChoBjKziC": "10000000000000000"
},
"lockedNotStakeables": {},
"utxoIDs": [
{
"txID": "11111111111111111111111111111111LpoYY",
"outputIndex": 1
},
{
"txID": "11111111111111111111111111111111LpoYY",
"outputIndex": 0
}
]
},
"id": 1
}
platform.getBlock
Retrieves a block by its ID.
Parameters
Signature:
platform.getBlock({
blockID: string
encoding: string // optional
}) -> {
block: string,
encoding: string
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):blockID: a block ID in cb58 format.encoding: the encoding format to use; can be either hex or json; defaults to hex.
Request example (hex)
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getBlock",
"params" :{
"blockID": "d7WYmb8VeZNHsny3EJCwMm6QA37s1EHwMxw1Y71V3FqPZ5EFG",
"encoding": "hex"
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"block": "0x00000000000309473dc99a0851a29174d84e522da8ccb1a56ac23f7b0ba79f80acce34cf576900000000000f4241000000010000001200000001000000000000000000000000000000000000000000000000000000000000000000000000000000011c4c57e1bcb3c567f9f03caa75563502d1a21393173c06d9d79ea247b20e24800000000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000050000000338e0465f0000000100000000000000000427d4b22a2a78bcddd456742caf91b56badbff985ee19aef14573e7343fd6520000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000070000000338d1041f0000000000000000000000010000000195a4467dd8f939554ea4e6501c08294386938cbf000000010000000900000001c79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed738580119286dde",
"encoding": "hex"
},
"id": 1
}
Request example (JSON)
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getBlock",
"params" :{
"blockID": "d7WYmb8VeZNHsny3EJCwMm6QA37s1EHwMxw1Y71V3FqPZ5EFG",
"encoding": "json"
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"block": {
"parentID": "5615di9ytxujackzaXNrVuWQy5y8Yrt8chPCscMr5Ku9YxJ1S",
"height": 1000001,
"txs": [
{
"unsignedTx": {
"inputs": {
"networkID": 1,
"blockchainID": "11111111111111111111111111111111LpoYY",
"outputs": [],
"inputs": [
{
"txID": "DTqiagiMFdqbNQ62V2Gt1GddTVLkKUk2caGr4pyza9hTtsfta",
"outputIndex": 0,
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
"input": {
"amount": 13839124063,
"signatureIndices": [0]
}
}
],
"memo": "0x"
},
"destinationChain": "2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5",
"exportedOutputs": [
{
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
"output": {
"addresses": [
"P-avax1jkjyvlwclyu42n4yuegpczpfgwrf8r9lyj0d3c"
],
"amount": 13838124063,
"locktime": 0,
"threshold": 1
}
}
]
},
"credentials": [
{
"signatures": [
"0xc79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed7385801"
]
}
]
}
]
},
"encoding": "json"
},
"id": 1
}
platform.getBlockchains
Retrieves all the blockchains that exist (excluding the P-Chain).
Parameters
Signature:
platform.getBlockchains() ->
{
blockchains: []{
id: string,
name:string,
subnetID: string,
vmID: string
}
}
Request parameters:
id(integer; required): a request ID (example: 1).jsonrpc(string; required): a JSON RPC spec used (example: 2.0).method(string; required): a method used for the request.params(object; required): None.
Response parameters:
blockchains: all of the blockchains that exists on the Avalanche network.name: the human-readable name of this blockchain.id: the blockchain ID.subnetID: the ID of the Subnet that validates this blockchain.vmID: the ID of the Virtual Machine the blockchain runs.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getBlockchains",
"params" :{}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"blockchains": [
{
"id": "2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM",
"name": "X-Chain",
"subnetID": "11111111111111111111111111111111LpoYY",
"vmID": "jvYyfQTxGMJLuGWa55kdP2p2zSUYsQ5Raupu4TW34ZAUBAbtq"
},
{
"id": "2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5",
"name": "C-Chain",
"subnetID": "11111111111111111111111111111111LpoYY",
"vmID": "mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6"
},
{
"id": "CqhF97NNugqYLiGaQJ2xckfmkEr8uNeGG5TQbyGcgnZ5ahQwa",
"name": "Simple DAG Payments",
"subnetID": "11111111111111111111111111111111LpoYY",
"vmID": "sqjdyTKUSrQs1YmKDTUbdUhdstSdtRTGRbUn8sqK8B6pkZkz1"
},
{
"id": "VcqKNBJsYanhVFxGyQE5CyNVYxL3ZFD7cnKptKWeVikJKQkjv",
"name": "Simple Chain Payments",
"subnetID": "11111111111111111111111111111111LpoYY",
"vmID": "sqjchUjzDqDfBPGjfQq2tXW1UCwZTyvzAWHsNzF2cb1eVHt6w"
},
{
"id": "2SMYrx4Dj6QqCEA3WjnUTYEFSnpqVTwyV3GPNgQqQZbBbFgoJX",
"name": "Simple Timestamp Server",
"subnetID": "11111111111111111111111111111111LpoYY",
"vmID": "tGas3T58KzdjLHhBDMnH2TvrddhqTji5iZAMZ3RXs2NLpSnhH"
},
{
"id": "KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN",
"name": "My new timestamp",
"subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r",
"vmID": "tGas3T58KzdjLHhBDMnH2TvrddhqTji5iZAMZ3RXs2NLpSnhH"
},
{
"id": "2TtHFqEAAJ6b33dromYMqfgavGPF3iCpdG3hwNMiart2aB5QHi",
"name": "My new AVM",
"subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r",
"vmID": "jvYyfQTxGMJLuGWa55kdP2p2zSUYsQ5Raupu4TW34ZAUBAbtq"
}
]
},
"id": 1
}
platform.getBlockchainStatus
Retrieves the status of a blockchain.
Parameters
Signature:
platform.getBlockchainStatus(
{
blockchainID: string
}
) -> {status: string}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):blockchainID: a blockchain ID to return the status for.
Response parameters:
status: either of the following: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: the node is participating in this blockchain as a non-validating node.Unknown: the blockchain either wasn’t proposed or the proposal to create it isn’t preferred. The proposal may be resubmitted.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getBlockchainStatus",
"params" :{
"blockchainID":"2NbS4dwGaf2p1MaXb65PrkZdXRwmSX4ZzGnUu7jm3aykgThuZE"}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"status": "Created"
},
"id": 1
}
platform.getCurrentSupply
Retrieves an upper bound on the amount of existing tokens that can stake the requested Subnet.
This is an upper bound because it does not account for burnt tokens, including transaction fees.
Parameters
Signature:
platform.getCurrentSupply({
subnetID: string // optional
}) -> {supply: int}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):subnetID: a Subnet ID.
Response parameters:
supply: an upper bound on the number of tokens that exist.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getCurrentSupply",
"params" :{
"subnetID":"11111111111111111111111111111111LpoYY"}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"supply": "365865167637779183"
},
"id": 1
}
platform.getCurrentValidators
Retrieves the list of current validators of the given Subnet.
Parameters
Signature:
platform.getCurrentValidators({
subnetID: string, // optional
nodeIDs: string[], // optional
}) -> {
validators: []{
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[]
},
potentialReward: string,
delegationFee: string,
uptime: string,
connected: bool,
signer: {
publicKey: string,
proofOfPosession: string
},
delegatorCount: string,
delegatorWeight: string,
delegators: []{
txID: string,
startTime: string,
endTime: string,
stakeAmount: string,
nodeID: string,
rewardOwner: {
locktime: string,
threshold: string,
addresses: string[]
},
potentialReward: string,
}
}
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):subnetID: the Subnet whose current validators are returned; if omitted, returns the current validators of the Primary Network.nodeIDs: a list of the NodeIDs of current validators to request; if omitted, all current validators are returned; if a specified NodeID is not in the set of current validators, it will not be included in the response.
Response parameters:
validators:txID: the validator transaction.startTime: the Unix time when the validator starts validating the Subnet.endTime: the Unix time when the validator stops validating the Subnet.stakeAmount: the amount of tokens this validator staked. Omitted ifsubnetIDis not a PoS Subnet.nodeID: the validator’s node ID.weight: the validator’s weight when sampling validators. Omitted ifsubnetIDis a PoS Subnet.validationRewardOwner: anOutputOwnersoutput which includeslocktime,threshold, and array ofaddresses. Specifies the owner of the potential reward earned from staking. Omitted ifsubnetIDis not a PoS Subnet.delegationRewardOwner: anOutputOwnersoutput which includeslocktime,threshold, and array ofaddresses. Specifies the owner of the potential reward earned from delegations. Omitted ifsubnetIDis not a PoS Subnet.potentialReward: the potential reward earned from staking. Omitted ifsubnetIDis not a PoS Subnet.delegationFeeRate: the percentage fee this validator charges when others delegate stake to them. Omitted ifsubnetIDis not a PoS Subnet.uptime: the % of time the queried node has reported the peer as online and validating the Subnet.connected: if the node is connected and tracks the Subnet.signer: the node's BLS public key and proof of possession. Omitted if the validator doesn't have a BLS public key.delegatorCount: the number of delegators on this validator. Omitted ifsubnetIDis not a PoS Subnet.delegatorWeight: total weight of delegators on this validator. Omitted ifsubnetIDis not a PoS Subnet.delegators: the list of delegators to this validator. Omitted ifsubnetIDis not a PoS Subnet. Omitted unlessnodeIDsspecifies a single NodeID.txID: the delegator transaction.startTime: the Unix time when the delegator started.endTime: the Unix time when the delegator stops.stakeAmount: the amount of nAVAX this delegator staked.nodeID: the validating node’s node ID.rewardOwner: anOutputOwnersoutput which includeslocktime,threshold, and array ofaddresses.potentialReward: the potential reward earned from staking.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getCurrentValidators",
"params" :{
"nodeIDs": ["NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD"]
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"validators": [
{
"txID": "2NNkpYTGfTFLSGXJcHtVv6drwVU2cczhmjK2uhvwDyxwsjzZMm",
"startTime": "1600368632",
"endTime": "1602960455",
"stakeAmount": "2000000000000",
"nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD",
"validationRewardOwner": {
"locktime": "0",
"threshold": "1",
"addresses": ["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"]
},
"delegationRewardOwner": {
"locktime": "0",
"threshold": "1",
"addresses": ["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"]
},
"potentialReward": "117431493426",
"delegationFee": "10.0000",
"uptime": "0.0000",
"connected": false,
"delegatorCount": "1",
"delegatorWeight": "25000000000",
"delegators": [
{
"txID": "Bbai8nzGVcyn2VmeYcbS74zfjJLjDacGNVuzuvAQkHn1uWfoV",
"startTime": "1600368523",
"endTime": "1602960342",
"stakeAmount": "25000000000",
"nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD",
"rewardOwner": {
"locktime": "0",
"threshold": "1",
"addresses": ["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"]
},
"potentialReward": "11743144774"
}
]
}
]
},
"id": 1
}
platform.getHeight
Retrieves the height of the latest accepted block.
Parameters
Signature:
platform.getHeight() ->
{
height: int,
}
Request parameters:
id(integer; required): a request ID (example: 1).jsonrpc(string; required): a JSON RPC spec used (example: 2.0).method(string; required): a method used for the request.params(object; required): None.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getHeight",
"params" :{}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"height": "56"
},
"id": 1
}
platform.getMaxStakeAmount
Retrieves the maximum amount of nAVAX staking to the named node during a particular time period.
Parameters
Signature:
platform.getMaxStakeAmount(
{
subnetID: string,
nodeID: string,
startTime: int,
endTime: int
}
) ->
{
amount: uint64
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):subnetID: a Buffer or cb58 string representing Subnet.nodeID: a string representing ID of the node whose stake amount is required during the given duration.startTime: a big number denoting start time of the duration during which stake amount of the node is required.endTime: a big number denoting end time of the duration during which stake amount of the node is required.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getMaxStakeAmount",
"params" :{
"subnetID":"11111111111111111111111111111111LpoYY",
"nodeID":"NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg",
"startTime": 1644240334,
"endTime": 1644240634
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"amount": "2000000000000000"
},
"id": 1
}
platform.getMinStake
Retrieves the minimum amount of tokens required to validate the requested Subnet and the minimum amount of tokens that can be delegated.
Parameters
Signature:
platform.getMinStake({
subnetID: string // optional
}) ->
{
minValidatorStake : uint64,
minDelegatorStake : uint64
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):subnetID: a string representing Subnet.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getMinStake",
"params" :{
"subnetID":"11111111111111111111111111111111LpoYY"
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"minValidatorStake": "2000000000000",
"minDelegatorStake": "25000000000"
},
"id": 1
}
platform.getPendingValidators
Retrieves the list of validators in the pending validator set of the specified Subnet.
Each validator is not currently validating the Subnet but will be doing so in the future.
Parameters
Signature:
platform.getPendingValidators({
subnetID: string, // optional
nodeIDs: string[], // optional
}) -> {
validators: []{
txID: string,
startTime: string,
endTime: string,
stakeAmount: string,
nodeID: string,
delegationFee: string,
connected: bool,
signer: {
publicKey: string,
proofOfPosession: string
},
weight: string,
},
delegators: []{
txID: string,
startTime: string,
endTime: string,
stakeAmount: string,
nodeID: string
}
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):subnetID: the Subnet whose current validators are returned; if omitted, returns the current validators of the Primary Network.nodeIDs: a list of the NodeIDs of pending validators to request; if omitted, all pending validators are returned; if a specified NodeID is not in the set of pending validators, it will not be included in the response.
Response parameters:
validators:txID: the validator transaction.startTime: the Unix time when the validator starts validating the Subnet.endTime: the Unix time when the validator stops validating the Subnet.stakeAmount: the amount of tokens this validator staked. Omitted if subnetID is not a PoS Subnet.nodeID: the validator’s node ID.connected: shows if the node is connected and tracks the Subnet.signer: the node's BLS public key and proof of possession. Omitted if the validator doesn't have a BLS public key.weightthe validator’s weight when sampling validators. Omitted if subnetID is a PoS Subnet.
delegators:txID: the delegator transaction.startTime: the Unix time when the delegator starts.endTime: the Unix time when the delegator stops.stakeAmount: the amount of tokens this delegator staked.nodeIDthe validating node’s node ID.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getPendingValidators",
"params" :{}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"validators": [
{
"txID": "2NNkpYTGfTFLSGXJcHtVv6drwVU2cczhmjK2uhvwDyxwsjzZMm",
"startTime": "1600368632",
"endTime": "1602960455",
"stakeAmount": "200000000000",
"nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD",
"delegationFee": "10.0000",
"connected": false
}
],
"delegators": [
{
"txID": "Bbai8nzGVcyn2VmeYcbS74zfjJLjDacGNVuzuvAQkHn1uWfoV",
"startTime": "1600368523",
"endTime": "1602960342",
"stakeAmount": "20000000000",
"nodeID": "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg"
}
]
},
"id": 1
}
platform.getRewardUTXOs
Retrieves the UTXOs rewarded after the provided transaction's staking or delegation period has ended.
Parameters
Signature:
platform.getRewardUTXOs({
txID: string,
encoding: string // optional
}) -> {
numFetched: integer,
utxos: []string,
encoding: string
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):txID: the ID of the staking or delegating transaction.
Response parameters:
numFetched: the number of returned UTXOs.utxos: an array of encoded reward UTXOs.encodingspecifies the format for the returned UTXOs; can only behexwhen a value is provided.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getRewardUTXOs",
"params" :{
"txID":"2nmH8LithVbdjaXsxVQCQfXtzN9hBbmebrsaEYnLM9T32Uy2Y5",
"encoding": "hex"
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"numFetched": "2",
"utxos": [
"0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765",
"0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a"
],
"encoding": "hex"
},
"id": 1
}
platform.getStake
Retrieves the amount of nAVAX staked by a set of addresses.
The amount returned does not include staking rewards.
Parameters
Signature:
platform.getStake({
addresses: []string,
validatorsOnly: true or false
}) ->
{
stakeds: string -> int,
stakedOutputs: []string,
encoding: string
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):addresses: the addresses to get information about.validatorsOnly: can be eithertrueorfalse. Iftrue, will skip checking delegators for stake.
Response parameters:
stakeds: a map from assetID to the amount staked by addresses provided.stakedOutputs: the string representation of staked outputs.encoding: specifies the format for the returned outputs.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getStake",
"params" :{
"addresses": [
"P-avax1pmgmagjcljjzuz2ve339dx82khm7q8getlegte"
],
"validatorsOnly": true
},
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"staked": "6500000000000",
"stakeds": {
"FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z": "6500000000000"
},
"stakedOutputs": [
"0x000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff00000007000005e96630e800000000000000000000000001000000011f1c933f38da6ba0ba46f8c1b0a7040a9a991a80dd338ed1"
],
"encoding": "hex"
},
"id": 1
}
platform.getStakingAssetID
Retrieves an assetID for a Subnet’s staking asset.
Parameters
Signature:
platform.getStakingAssetID({
subnetID: string // optional
}) -> {
assetID: string
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):subnetID: the Subnet whose assetID is requested.
Response parameters:
assetID: the assetID for a Subnet’s staking asset.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getStakingAssetID",
"params" :{
"subnetID": "11111111111111111111111111111111LpoYY"
},
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe"
},
"id": 1
}
platform.getSubnets
Retrieves info about the Subnets.
Parameters
Signature:
platform.getSubnets({
ids: []string
}) ->
{
subnets: []{
id: string,
controlKeys: []string,
threshold: string
}
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):ids: the IDs of the Subnets to get information about. If omitted, gets information about all Subnets.
Response parameters:
subnets:id: the Subnet’s ID.threshold: signatures from addresses incontrolKeysare needed to add a validator to the Subnet; if the Subnet is a PoS Subnet, thenthresholdwill be0andcontrolKeyswill be empty.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getSubnets",
"params" :{
"ids":[
"hW8Ma7dLMA7o4xmJf3AXBbo17bXzE7xnThUd3ypM4VAWo1sNJ"
]
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"subnets": [
{
"id": "hW8Ma7dLMA7o4xmJf3AXBbo17bXzE7xnThUd3ypM4VAWo1sNJ",
"controlKeys": [
"KNjXsaA1sZsaKCD1cd85YXauDuxshTes2",
"Aiz4eEt5xv9t4NCnAWaQJFNz5ABqLtJkR"
],
"threshold": "2"
}
]
},
"id": 1
}
platform.getTimestamp
Retrieves the current P-Chain timestamp.
Parameters
Signature:
platform.getTimestamp() -> {time: string}
Request parameters:
id(integer; required): a request ID (example: 1).jsonrpc(string; required): a JSON RPC spec used (example: 2.0).method(string; required): a method used for the request.params(object; required): None.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getTimestamp",
"params" :{}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"timestamp": "2021-09-07T00:00:00-04:00"
},
"id": 1
}
platform.getTotalStake
Retrieves the total amount of tokens staked on the requested Subnet.
Parameters
Signature:
platform.getTotalStake({
subnetID: string
}) -> {
stake: int
weight: int
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):subnetID: a string of a Subnet.
Request example (Primary network)
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getTotalStake",
"params" :{
"subnetID": "11111111111111111111111111111111LpoYY"
}
}'
Response example (Primary network)
{
"jsonrpc": "2.0",
"result": {
"stake": "279825917679866811",
"weight": "279825917679866811"
},
"id": 1
}
Request example (Subnet)
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getTotalStake",
"params" :{
"subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r"
}
}'
Response example (Subnet)
{
"jsonrpc": "2.0",
"result": {
"weight": "100000"
},
"id": 1
}
platform.getTx
Retrieves a transaction by its ID.
Optional encoding parameter to specify the format for the returned transaction. Can be either hex or json. Defaults to hex.
Parameters
Signature:
platform.getTx({
txID: string,
encoding: string // optional
}) -> {
tx: string,
encoding: string,
}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):txID: a string of a transaction ID.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getTx",
"params" :{
"txID": "28KVjSw5h3XKGuNpJXWY74EdnGq4TUWvCgEtJPymgQTvudiugb",
"encoding": "json"
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"tx": {
"unsignedTx": {
"networkID": 1,
"blockchainID": "11111111111111111111111111111111LpoYY",
"outputs": [],
"inputs": [
{
"txID": "NXNJHKeaJyjjWVSq341t6LGQP5UNz796o1crpHPByv1TKp9ZP",
"outputIndex": 0,
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
"input": {
"amount": 20824279595,
"signatureIndices": [
0
]
}
},
{
"txID": "2ahK5SzD8iqi5KBqpKfxrnWtrEoVwQCqJsMoB9kvChCaHgAQC9",
"outputIndex": 1,
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
"input": {
"amount": 28119890783,
"signatureIndices": [
0
]
}
}
],
"memo": "0x",
"validator": {
"nodeID": "NodeID-VT3YhgFaWEzy4Ap937qMeNEDscCammzG",
"start": 1682945406,
"end": 1684155006,
"weight": 48944170378
},
"stake": [
{
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
"output": {
"addresses": [
"P-avax1tnuesf6cqwnjw7fxjyk7lhch0vhf0v95wj5jvy"
],
"amount": 48944170378,
"locktime": 0,
"threshold": 1
}
}
],
"rewardsOwner": {
"addresses": [
"P-avax19zfygxaf59stehzedhxjesads0p5jdvfeedal0"
],
"locktime": 0,
"threshold": 1
}
},
"credentials": [
{
"signatures": [
"0x6954e90b98437646fde0c1d54c12190fc23ae5e319c4d95dda56b53b4a23e43825251289cdc3728f1f1e0d48eac20e5c8f097baa9b49ea8a3cb6a41bb272d16601"
]
},
{
"signatures": [
"0x6954e90b98437646fde0c1d54c12190fc23ae5e319c4d95dda56b53b4a23e43825251289cdc3728f1f1e0d48eac20e5c8f097baa9b49ea8a3cb6a41bb272d16601"
]
}
],
"id": "28KVjSw5h3XKGuNpJXWY74EdnGq4TUWvCgEtJPymgQTvudiugb"
},
"encoding": "json"
},
"id": 1
}
platform.getTxStatus
Retrieves a transaction’s status by its ID.
If the transaction was dropped, response will include a reason field with more information why the transaction was dropped.
Parameters
Signature:
platform.getTxStatus({
txID: string
}) -> {status: string}
Request parameters:
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(object; required):txID: a string of a transaction ID.
Response parameters:
status: either of the following:Committed: the transaction is (or will be) accepted by every node.Processing: the transaction is being voted on by this node.Dropped: the transaction will never be accepted by any node in the network, check reason field for more information.Unknown: the transaction hasn’t been seen by this node.
Request example
curl -X POST 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getTxStatus",
"params" :{
"txID":"TAG9Ns1sa723mZy1GSoGqWipK6Mvpaj7CAswVJGM6MkVJDF9Q"
}
}'
Response example
{
"jsonrpc": "2.0",
"result": {
"status": "Committed"
},
"id": 1
}