Platform Chain (P-Chain) API
This API allows clients to interact with the P-Chain, which maintains Metal's validator set and handles blockchain creation.
Endpoint
/ext/bc/P
Format
This API uses the json 2.0
RPC format.
Methods
platform.addDelegator
Not recommended for use on Mainnet. See warning notice in Keystore API.
Add a delegator to the Primary Network.
A delegator stakes METAL and specifies a validator (the delegatee) to validate on their behalf. The delegatee has an increased probability of being sampled by other validators (weight) in proportion to the stake delegated to them.
The delegatee charges a fee to the delegator; the former receives a percentage of the delegator’s validation reward (if any.) A transaction that delegates stake has no fee.
The delegation period must be a subset of the period that the delegatee validates the Primary Network.
Once you issue the transaction to add a node as a delegator, there is no way to change the parameters. You can’t remove a stake early or change the stake amount, node ID, or reward address. Please make sure you’re using the correct values.
Signature
platform.addDelegator(
{
nodeID: string,
startTime: int,
endTime: int,
stakeAmount: int,
rewardAddress: string,
from: []string, // optional
changeAddr: string, // optional
username: string,
password: string
}
) ->
{
txID: string,
changeAddr: string
}
nodeID
is the ID of the node to delegate to.startTime
is the Unix time when the delegator starts delegating.endTime
is the Unix time when the delegator stops delegating (and staked METAL is returned).stakeAmount
is the amount of nMETAL the delegator is staking.rewardAddress
is the address the validator reward goes to, if there is one.from
are the addresses that you want to use for this operation. If omitted, uses any of your addresses as needed.changeAddr
is the address any change will be sent to. If omitted, change is sent to one of the addresses controlled by the user.username
is the user that pays the transaction fee.password
isusername
‘s password.txID
is the transaction ID
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.addDelegator",
"params": {
"nodeID":"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ",
"rewardAddress":"P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"startTime":1594102400,
"endTime":1604102400,
"stakeAmount":100000,
"from": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u",
"username":"myUsername",
"password":"myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"txID": "6pB3MtHUNogeHapZqMUBmx6N38ii3LzytVDrXuMovwKQFTZLs",
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u"
},
"id": 1
}
platform.addValidator
Not recommended for use on Mainnet. See warning notice in Keystore API.
Add a validator to the Primary Network. You must stake METAL to do this. If the node is sufficiently correct and responsive while validating, you receive a reward when end of staking period is reached. The validator’s probability of being sampled by other validators during consensus is in proportion to the amount of METAL staked.
The validator charges a fee to delegators; the former receives a percentage of the delegator’s validation reward (if any.) The minimum delegation fee is 2%. A transaction that adds a validator has no fee.
The validation period must be between 2 weeks and 1 year for the Mainnet, and 24 hours and 1 year for Tahoe Testnet.
There is a maximum total weight imposed on validators. This means that no validator will ever have more METAL staked and delegated to it than this value. This value will initially be set to min(5 * amount staked, 3M METAL)
. The total value on a validator is 3 million METAL.
Note that once you issue the transaction to add a node as a validator, there is no way to change the parameters. You can’t remove stake early or change the stake amount, node ID, or reward address. Please make sure you’re using the correct values.
Signature
platform.addValidator(
{
nodeID: string,
startTime: int,
endTime: int,
stakeAmount: int,
rewardAddress: string,
delegationFeeRate: float,
from: []string, // optional
changeAddr: string, // optional
username: string,
password: string
}
) ->
{
txID: string,
changeAddr: string
}
nodeID
is the node ID of the validator being added.startTime
is the Unix time when the validator starts validating the Primary Network.endTime
is the Unix time when the validator stops validating the Primary Network (and staked METAL is returned).stakeAmount
is the amount of nMETAL the validator is staking.rewardAddress
is the address the validator reward will go to, if there is one.delegationFeeRate
is the percent fee this validator charges when others delegate stake to them. Up to 4 decimal places allowed; additional decimal places are ignored. Must be between 0 and 100, inclusive. For example, ifdelegationFeeRate
is1.2345
and someone delegates to this validator, then when the delegation period is over, 1.2345% of the reward goes to the validator and the rest goes to the delegator.from
are the addresses that you want to use for this operation. If omitted, uses any of your addresses as needed.changeAddr
is the address any change will be sent to. If omitted, change is sent to one of the addresses controlled by the user.username
is the user that pays the transaction fee.password
isusername
‘s password.txID
is the transaction ID
Example Call
In this example, we use shell command date
to compute Unix times 10 minutes and 2 days in the future. (Note: If you’re on a Mac, replace $(date
with $(gdate
. If you don’t have gdate
installed, do brew install coreutils
.)
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.addValidator",
"params": {
"nodeID":"NodeID-ARCLrphAHZ28xZEBfUL7SVAmzkTZNe1LK",
"rewardAddress":"P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"from": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u",
"startTime":'$(date --date="10 minutes" +%s)',
"endTime":'$(date --date="2 days" +%s)',
"stakeAmount":1000000,
"delegationFeeRate":10,
"username":"myUsername",
"password":"myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"txID": "6pb3mthunogehapzqmubmx6n38ii3lzytvdrxumovwkqftzls",
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u"
},
"id": 1
}
platform.addSubnetValidator
Not recommended for use on Mainnet. See warning notice in Keystore API.
Add a validator to a Subnet other than the Primary Network. The Validator must validate the Primary Network for the entire duration they validate this Subnet.
Signature
platform.addSubnetValidator(
{
nodeID: string,
subnetID: string,
startTime: int,
endTime: int,
weight: int,
from: []string, // optional
changeAddr: string, // optional
username: string,
password: string
}
) ->
{
txID: string,
changeAddr: string,
}
nodeID
is the node ID of the validator being added to the Subnet. This validator must validate the Primary Network for the entire duration that it validates this Subnet.subnetID
is the ID of the Subnet we’re adding a validator to.startTime
is the unix time when the validator starts validating the Subnet. It must be at or after the time that the validator starts validating the Primary NetworkendTime
is the unix time when the validator stops validating the Subnet. It must be at or before the time that the validator stops validating the Primary Network.weight
is the validator’s weight used for sampling. If the validator’s weight is 1 and the cumulative weight of all validators in the Subnet is 100, then this validator will be included in about 1 in every 100 samples during consensus. The cumulative weight of all validators in the Subnet must be at leastsnow-sample-size
. For example, if there is only one validator in the Subnet, its weight must be at leastsnow-sample-size
(default 20). Recall that a validator's weight can't be changed while it is validating, so take care to use an appropriate value.from
are the fund addresses that the user wants to use to pay for this operation. If omitted, use any of user's addresses as needed.changeAddr
is the address any change/left-over of the fund (specified by thefrom
addresses) will be sent to. If omitted, change/left-over is sent to one of the addresses controlled by the user.username
is the user that pays the transaction fee.password
isusername
‘s password.txID
is the transaction ID.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.addSubnetValidator",
"params": {
"nodeID":"NodeID-7xhw2mdxuds44j42tcb6u5579esbst3lg",
"subnetID":"zbfoww1ffkpvrfywpj1cvqrfnyesepdfc61hmu2n9jnghduel",
"startTime":1583524047,
"endTime":1604102399,
"weight":1,
"from": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u",
"username":"myUsername",
"password":"myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"txID": "2exafyvRNSE5ehwjhafBVt6CTntot7DFjsZNcZ54GSxBbVLcCm",
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u"
}
}
platform.createAddress
Not recommended for use on Mainnet. See warning notice in Keystore API.
Create a new address controlled by the given user.
Signature
platform.createAddress({
username: string,
password: string
}) -> {address: string}
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.createAddress",
"params": {
"username":"myUsername",
"password":"myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"address": "P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"
},
"id": 1
}
platform.createBlockchain
Not recommended for use on Mainnet. See warning notice in Keystore API.
Create a new blockchain. Currently only supports the creation of new instances of the AVM and the Timestamp VM.
Signature
platform.createBlockchain(
{
subnetID: string,
vmID: string,
name: string,
genesisData: string,
encoding: string, // optional
from: []string, // optional
changeAddr: string, // optional
username: string,
password: string
}
) ->
{
txID: string,
changeAddr: string
}
subnetID
is the ID of the Subnet that validates the new blockchain. The Subnet must exist and can’t be the Primary Network.vmID
is the ID of the Virtual Machine the blockchain runs. Can also be an alias of the Virtual Machine.name
is a human-readable name for the new blockchain. Not necessarily unique.genesisData
is the byte representation of the genesis state of the new blockchain encoded in the format specified by theencoding
parameter.encoding
specifies the format to use forgenesisData
. Can only behex
when a value is provided. Virtual Machines should have a static API method namedbuildGenesis
that can be used to generategenesisData
from
are the addresses that you want to use for this operation. If omitted, uses any of your addresses as needed.changeAddr
is the address any change will be sent to. If omitted, change is sent to one of the addresses controlled by the user.username
is the user that pays the transaction fee. This user must have a sufficient number of the subnet’s control keys.password
isusername
‘s password.txID
is the transaction ID.
Example Call
In this example we’re creating a new instance of the Timestamp Virtual Machine. genesisData
came from calling timestamp.buildGenesis
.
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.createBlockchain",
"params" : {
"vmID":"timestamp",
"subnetID":"2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r",
"name":"My new timestamp",
"genesisData": "0x07000000000000000000000000000000000000000000000000000000000000000016943a",
"encoding": "hex",
"from": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u",
"username":"myUsername",
"password":"myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"txID": "2TBnyFmST7TirNm6Y6z4863zusRVpWi5Cj1sKS9bXTUmu8GfeU",
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u"
},
"id": 1
}
platform.createSubnet
Not recommended for use on Mainnet. See warning notice in Keystore API.
Create a new Subnet.
The Subnet’s ID is the same as this transaction’s ID.
Signature
platform.createSubnet(
{
controlKeys: []string,
threshold: int,
from: []string, // optional
changeAddr: string, // optional
username: string,
password: string
}
) ->
{
txID: string,
changeAddr: string
}
- In order to add a validator to this Subnet,
threshold
signatures are required from the addresses incontrolKeys
from
are the addresses that you want to use for this operation. If omitted, uses any of your addresses as needed.changeAddr
is the address any change will be sent to. If omitted, change is sent to one of the addresses controlled by the user.username
is the user that pays the transaction fee.password
isusername
‘s password.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.createSubnet",
"params": {
"controlKeys":[
"P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"
],
"threshold":2,
"from": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u",
"username":"myUsername",
"password":"myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"txID": "hJfC5xGhtjhCGBh1JWn3vZ51KJP696TZrsbadPHNbQG2Ve5yd"
},
"id": 1
}
platform.exportAVAX
Send AVAX from an address on the P-Chain to an address on the X-Chain or C-Chain. After issuing this transaction, you must call the X-Chain's avm.import
or C-Chain's avax.import
with assetID AVAX
to complete the transfer.
Signature
platform.exportAVAX(
{
amount: int,
from: []string, // optional
to: string,
changeAddr: string, // optional
username: string,
password: string
}
) ->
{
txID: string,
changeAddr: string
}
amount
is the amount of nAVAX to send.to
is the address on the X-Chain or C-Chain to send the AVAX to.from
are the addresses that you want to use for this operation. If omitted, uses any of your addresses as needed.changeAddr
is the address any change will be sent to. If omitted, change is sent to one of the addresses controlled by the user.username
is the user sending the AVAX and paying the transaction fee.password
isusername
‘s password.txID
is the ID of this transaction.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.exportAVAX",
"params": {
"to":"X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"amount":1,
"from": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u",
"username":"myUsername",
"password":"myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"txID": "2Kz69TNBSeABuaVjKa6ZJCTLobbe5xo9c5eU8QwdUSvPo2dBk3",
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u"
},
"id": 1
}
platform.exportKey
Not recommended for use on Mainnet. See warning notice in Keystore API.
Get the private key that controls a given address.
The returned private key can be added to a user with platform.importKey
.
Signature
platform.exportKey({
username: string,
password: string,
address: string
}) -> {privateKey: string}
username
is the user that controlsaddress
.password
isusername
‘s password.privateKey
is the string representation of the private key that controlsaddress
.
Example Call
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.exportKey",
"params" :{
"username" :"myUsername",
"password": "myPassword",
"address": "P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"privateKey": "PrivateKey-Lf49kAJw3CbaL783vmbeAJvhscJqC7vi5yBYLxw2XfbzNS5RS"
}
}
platform.getBalance
Get the balance of METAL controlled by a given address.
Signature
platform.getBalance({
address:string
}) -> {
balance: string,
unlocked: string,
lockedStakeable: string,
lockedNotStakeable: string,
utxoIDs: []{
txID: string,
outputIndex: int
}
}
address
is the address to get the balance of.balance
is the total balance, in nMETAL.unlocked
is the unlocked balance, in nMETAL.lockedStakeable
is the locked stakeable balance, in nMETAL.lockedNotStakeable
is the locked and not stakeable balance, in nMETAL.utxoIDs
are the IDs of the UTXOs that referenceaddress
.
Example Call
curl -X POST --data '{
"jsonrpc":"2.0",
"id" : 1,
"method" :"platform.getBalance",
"params" :{
"address":"P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"balance": "20000000000000000",
"unlocked": "10000000000000000",
"lockedStakeable": "10000000000000000",
"lockedNotStakeable": "0",
"utxoIDs": [
{
"txID": "11111111111111111111111111111111LpoYY",
"outputIndex": 1
},
{
"txID": "11111111111111111111111111111111LpoYY",
"outputIndex": 0
}
]
},
"id": 1
}
platform.getBlock
Get a block by its ID.
Signature
platform.getBlock({
blockID: string
encoding: string // optional
}) -> {
block: string,
encoding: string
}
Request
blockID
is the block ID. It should be in cb58 format.encoding
is the encoding format to use. Can be eitherhex
orjson
. Defaults tohex
.
Response
block
is the transaction encoded toencoding
.encoding
is theencoding
.
Hex Example
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getBlock",
"params": {
"blockID": "d7WYmb8VeZNHsny3EJCwMm6QA37s1EHwMxw1Y71V3FqPZ5EFG",
"encoding": "hex"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"block": "0x00000000000309473dc99a0851a29174d84e522da8ccb1a56ac23f7b0ba79f80acce34cf576900000000000f4241000000010000001200000001000000000000000000000000000000000000000000000000000000000000000000000000000000011c4c57e1bcb3c567f9f03caa75563502d1a21393173c06d9d79ea247b20e24800000000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000050000000338e0465f0000000100000000000000000427d4b22a2a78bcddd456742caf91b56badbff985ee19aef14573e7343fd6520000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000070000000338d1041f0000000000000000000000010000000195a4467dd8f939554ea4e6501c08294386938cbf000000010000000900000001c79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed738580119286dde",
"encoding": "hex"
},
"id": 1
}
JSON Example
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getBlock",
"params": {
"blockID": "d7WYmb8VeZNHsny3EJCwMm6QA37s1EHwMxw1Y71V3FqPZ5EFG",
"encoding": "json"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"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-metal1jkjyvlwclyu42n4yuegpczpfgwrf8r9lyj0d3c"
],
"amount": 13838124063,
"locktime": 0,
"threshold": 1
}
}
]
},
"credentials": [
{
"signatures": [
"0xc79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed7385801"
]
}
]
}
]
},
"encoding": "json"
},
"id": 1
}
platform.getBlockchains
Get all the blockchains that exist (excluding the P-Chain).
Signature
platform.getBlockchains() ->
{
blockchains: []{
id: string,
name:string,
subnetID: string,
vmID: string
}
}
blockchains
is all of the blockchains that exists on the Metal network.name
is the human-readable name of this blockchain.id
is the blockchain’s ID.subnetID
is the ID of the Subnet that validates this blockchain.vmID
is the ID of the Virtual Machine the blockchain runs.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getBlockchains",
"params": {},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"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
Get the status of a blockchain.
Signature
platform.getBlockchainStatus(
{
blockchainID: string
}
) -> {status: string}
status
is one of:
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 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.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getBlockchainStatus",
"params":{
"blockchainID":"2NbS4dwGaf2p1MaXb65PrkZdXRwmSX4ZzGnUu7jm3aykgThuZE"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"status": "Created"
},
"id": 1
}
platform.getCurrentSupply
Returns an upper bound on the number of METAL that exist. This is an upper bound because it does not account for burnt tokens, including transaction fees.
Signature
platform.getCurrentSupply() -> {supply: int}
supply
is an upper bound on the number of METAL that exist, denominated in nMETAL.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getCurrentSupply",
"params": {},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"supply": "365865167637779183"
},
"id": 1
}
The response in this example indicates that METAL's supply is at most 365.865 million.
platform.getCurrentValidators
List the current validators of the given Subnet.
Signature
platform.getCurrentValidators({
subnetID: string, // optional
nodeIDs: string[], // optional
}) -> {
validators: []{
txID: string,
startTime: string,
endTime: string,
stakeAmount: string,
nodeID: string,
weight: string,
rewardOwner: {
locktime: string,
threshold: string,
addresses: string[]
},
potentialReward: string,
delegationFee: string,
uptime: string,
connected: bool,
delegators: []{
txID: string,
startTime: string,
endTime: string,
stakeAmount: string,
nodeID: string,
rewardOwner: {
locktime: string,
threshold: string,
addresses: string[]
},
potentialReward: string,
}
}
}
subnetID
is the Subnet whose current validators are returned. If omitted, returns the current validators of the Primary Network.nodeIDs
is 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.validators
:txID
is the validator transaction.startTime
is the Unix time when the validator starts validating the Subnet.endTime
is the Unix time when the validator stops validating the Subnet.stakeAmount
is the amount of nMETAL this validator staked. Omitted ifsubnetID
is not the Primary Network.nodeID
is the validator’s node ID.weight
is the validator’s weight when sampling validators. Omitted ifsubnetID
is the Primary Network.rewardOwner
is anOutputOwners
output which includeslocktime
,threshold
and array ofaddresses
. Omitted ifsubnetID
is not the Primary Network.potentialReward
is the potential reward earned from staking. Omitted ifsubnetID
is not the Primary Network.delegationFeeRate
is the percent fee this validator charges when others delegate stake to them. Omitted ifsubnetID
is not the Primary Network.uptime
is the % of time the queried node has reported the peer as online. Omitted ifsubnetID
is not the Primary Network.connected
is if the node is connected and tracks the Subnet.delegators
is the list of delegators to this validator. Omitted ifsubnetID
is not the Primary Network.txID
is the delegator transaction.startTime
is the Unix time when the delegator started.endTime
is the Unix time when the delegator stops.stakeAmount
is the amount of nMETAL this delegator staked.nodeID
is the validating node’s node ID.rewardOwner
is anOutputOwners
output which includeslocktime
,threshold
and array ofaddresses
.potentialReward
is the potential reward earned from staking
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getCurrentValidators",
"params": {},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"validators": [
{
"txID": "2NNkpYTGfTFLSGXJcHtVv6drwVU2cczhmjK2uhvwDyxwsjzZMm",
"startTime": "1600368632",
"endTime": "1602960455",
"stakeAmount": "2000000000000",
"nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD",
"rewardOwner": {
"locktime": "0",
"threshold": "1",
"addresses": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"]
},
"potentialReward": "117431493426",
"delegationFee": "10.0000",
"uptime": "0.0000",
"connected": false,
"delegators": [
{
"txID": "Bbai8nzGVcyn2VmeYcbS74zfjJLjDacGNVuzuvAQkHn1uWfoV",
"startTime": "1600368523",
"endTime": "1602960342",
"stakeAmount": "25000000000",
"nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD",
"rewardOwner": {
"locktime": "0",
"threshold": "1",
"addresses": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"]
},
"potentialReward": "11743144774"
}
]
}
]
},
"id": 1
}
platform.getHeight
Returns the height of the last accepted block.
Signature
platform.getHeight() ->
{
height: int,
}
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getHeight",
"params": {},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"height": "56"
},
"id": 1
}
platform.getMaxStakeAmount
Returns the maximum amount of nMETAL staking to the named node during a particular time period.
Signature
platform.getMaxStakeAmount(
{
subnetID: string,
nodeID: string,
startTime: int,
endTime: int
}
) ->
{
amount: uint64
}
subnetID
is a Buffer or cb58 string representing SubnetnodeID
is a string representing ID of the node whose stake amount is required during the given durationstartTime
is a big number denoting start time of the duration during which stake amount of the node is required.endTime
is a big number denoting end time of the duration during which stake amount of the node is required.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getMaxStakeAmount",
"params": {
"subnetID":"11111111111111111111111111111111LpoYY",
"nodeID":"NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg",
"startTime": 1644240334,
"endTime": 1644240634
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"amount": "2000000000000000"
},
"id": 1
}
platform.getMinStake
Get the minimum amount of METAL required to validate the Primary Network and the minimum amount of METAL that can be delegated.
Signature
platform.getMinStake() ->
{
minValidatorStake : uint64,
minDelegatorStake : uint64
}
Example Call
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getMinStake"
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"minValidatorStake": "2000000000000",
"minDelegatorStake": "25000000000"
},
"id": 1
}
platform.getPendingValidators
List the validators in the pending validator set of the specified Subnet. Each validator is not currently validating the Subnet but will in the future.
Signature
platform.getPendingValidators({
subnetID: string, // optional
nodeIDs: string[], // optional
}) -> {
validators: []{
txID: string,
startTime: string,
endTime: string,
stakeAmount: string,
nodeID: string,
delegationFee: string,
connected: bool,
weight: string,
},
delegators: []{
txID: string,
startTime: string,
endTime: string,
stakeAmount: string,
nodeID: string
}
}
subnetID
is the Subnet whose current validators are returned. If omitted, returns the current validators of the Primary Network.nodeIDs
is 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.validators
:txID
is the validator transaction.startTime
is the Unix time when the validator starts validating the Subnet.endTime
is the Unix time when the validator stops validating the Subnet.stakeAmount
is the amount of nMETAL this validator staked. Omitted ifsubnetID
is not the Primary Network.nodeID
is the validator’s node ID.connected
if the node is connected and tracks the Subnet.weight
is the validator’s weight when sampling validators. Omitted ifsubnetID
is the Primary Network.
delegators
:txID
is the delegator transaction.startTime
is the Unix time when the delegator starts.endTime
is the Unix time when the delegator stops.stakeAmount
is the amount of nMETAL this delegator staked. Omitted ifsubnetID
is not the Primary Network.nodeID
is the validating node’s node ID.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getPendingValidators",
"params": {},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"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
Returns the UTXOs that were rewarded after the provided transaction's staking or delegation period ended.
Signature
platform.getRewardUTXOs({
txID: string,
encoding: string // optional
}) -> {
numFetched: integer,
utxos: []string,
encoding: string
}
txID
is the ID of the staking or delegating transactionnumFetched
is the number of returned UTXOsutxos
is an array of encoded reward UTXOsencoding
specifies the format for the returned UTXOs. Can only behex
when a value is provided.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getRewardUTXOs",
"params": {
"txID": "2nmH8LithVbdjaXsxVQCQfXtzN9hBbmebrsaEYnLM9T32Uy2Y5"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"numFetched": "2",
"utxos": [
"0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765",
"0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a"
],
"encoding": "hex"
},
"id": 1
}
platform.getStakingAssetID
Retrieve an assetID for a subnet’s staking asset. Currently, this only returns the Primary Network’s staking assetID.
Signature
platform.getStakingAssetID({
subnetID: string // optional
}) -> {
assetID: string
}
subnetID
is the Subnet whose assetID is requested.assetID
is the assetID for a subnet’s staking asset.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getStakingAssetID",
"params": {
"subnetID": "11111111111111111111111111111111LpoYY"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe"
},
"id": 1
}
platform.getSubnets
Get info about the Subnets.
Signature
platform.getSubnets(
{ids: []string}
) ->
{
subnets: []{
id: string,
controlKeys: []string,
threshold: string
}
}
ids
are the IDs of the Subnets to get information about. If omitted, gets information about all Subnets.id
is the Subnet’s ID.threshold
signatures from addresses incontrolKeys
are needed to add a validator to the Subnet.
See here for information on adding a validator to a Subnet.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getSubnets",
"params": {"ids":["hW8Ma7dLMA7o4xmJf3AXBbo17bXzE7xnThUd3ypM4VAWo1sNJ"]},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"subnets": [
{
"id": "hW8Ma7dLMA7o4xmJf3AXBbo17bXzE7xnThUd3ypM4VAWo1sNJ",
"controlKeys": [
"KNjXsaA1sZsaKCD1cd85YXauDuxshTes2",
"Aiz4eEt5xv9t4NCnAWaQJFNz5ABqLtJkR"
],
"threshold": "2"
}
]
},
"id": 1
}
platform.getStake
Get the amount of nMETAL staked by a set of addresses. The amount returned does not include staking rewards.
Signature
platform.getStake(
{addresses: []string}
) ->
{
staked: int,
stakedOutputs: []string,
encoding: string
}
addresses
are the addresses to get information about.staked
is the amount of nMETAL staked by addresses provided.stakedOutputs
are the string representation of staked outputs.encoding
specifies the format for the returned outputs.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getStake",
"params": {
"addresses": [
"P-metal1pmgmagjcljjzuz2ve339dx82khm7q8getlegte"
]
},
"id": 1
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"staked": "26870333254",
"stakedOutputs": [
"0x000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff00000007000000064198bf46000000000000000000000001000000010ed1bea258fca42e094ccc625698eab5f7e01d190f0f332d"
],
"encoding": "hex"
},
"id": 1
}
platform.getTimestamp
Get the current P-Chain timestamp.
Signature
platform.getTimestamp() -> {time: string}
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getTimestamp",
"params": {},
"id": 1
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"timestamp": "2021-09-07T00:00:00-04:00"
},
"id": 1
}
platform.getTotalStake
Get the total amount of nMETAL staked on the Primary Network.
Signature
platform.getTotalStake(subnetID: string) -> {stake: int}
Primary Network Example
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getTotalStake",
"params": {},
"id": 1
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"stake": "279825917679866811"
},
"id": 1
}
Subnet Example
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getTotalStake",
"params": {
"subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r",
},
"id": 1
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"weight": "100000"
},
"id": 1
}
platform.getTx
Gets 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".
Signature
platform.getTx({
txID: string,
encoding: string // optional
}) -> {
tx: string,
encoding: string,
}
JSON Example
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getTx",
"params": {
"txID":"2Eug3Y6j1yD745y5bQ9bFCf5nvU2qT1eB53GSpD15EkGUfu8xh",
"encoding": "json"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"tx": {
"unsignedTx": {
"inputs": {
"networkID": 5,
"blockchainID": "11111111111111111111111111111111LpoYY",
"outputs": [],
"inputs": [
{
"txID": "2QYG5yR6YW55ixmBvR4zXLCZKV9we9bmSWHHiGppF4Ko17bTPn",
"outputIndex": 0,
"assetID": "U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK",
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
"input": {
"amount": 1998000000,
"signatureIndices": [0]
}
}
],
"memo": "0x"
},
"destinationChain": "yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp",
"exportedOutputs": [
{
"assetID": "U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK",
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
"output": {
"addresses": ["P-tahoe1yhem6kev6gkfsyse3m5z09e6qsuxujz0arpw8v"],
"amount": 1997000000,
"locktime": 0,
"threshold": 1
}
}
]
},
"credentials": [
{
"signatures": [
"0xdbc03ebd7d06927baacf7aea85cdebd7e0b95cf5b57715a09981fd5a75dac2cb610636bf3657ba4ca47dad4beed2e7f0ec692e7f12f1bbc9f3c34fc5c18ae35d01"
]
}
]
},
"encoding": "json"
},
"id": 1
}
platform.getTxStatus
Gets 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.
Signature
platform.getTxStatus({
txID: string
}) -> {status: string}
status
is one of:
Committed
: The transaction is (or will be) accepted by every nodeProcessing
: The transaction is being voted on by this nodeDropped
: The transaction will never be accepted by any node in the network, checkreason
field for more informationUnknown
: The transaction hasn’t been seen by this node
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getTxStatus",
"params": {
"txID":"TAG9Ns1sa723mZy1GSoGqWipK6Mvpaj7CAswVJGM6MkVJDF9Q"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"status": "Committed"
},
"id": 1
}
platform.getUTXOs
Gets the UTXOs that reference a given set of addresses.
Signature
platform.getUTXOs(
{
addresses: []string,
limit: int, // optional
startIndex: { // optional
address: string,
utxo: string
},
sourceChain: string, // optional
encoding: string, // optional
},
) ->
{
numFetched: int,
utxos: []string,
endIndex: {
address: string,
utxo: string
},
encoding: string,
}
utxos
is a list of UTXOs such that each UTXO references at least one address inaddresses
.- At most
limit
UTXOs are returned. Iflimit
is omitted or greater than 1024, it is set to 1024. - This method supports pagination.
endIndex
denotes the last UTXO returned. To get the next set of UTXOs, use the value ofendIndex
asstartIndex
in the next call. - If
startIndex
is omitted, will fetch all UTXOs up tolimit
. - When using pagination (ie when
startIndex
is provided), UTXOs are not guaranteed to be unique across multiple calls. That is, a UTXO may appear in the result of the first call, and then again in the second call. - When using pagination, consistency is not guaranteed across multiple calls. That is, the UTXO set of the addresses may have changed between calls.
encoding
specifies the format for the returned UTXOs. Can only behex
when a value is provided.
Example
Suppose we want all UTXOs that reference at least one of P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5
and P-metal1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6
.
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getUTXOs",
"params" :{
"addresses":["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "P-metal1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6"],
"limit":5,
"encoding": "hex"
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
This gives response:
{
"jsonrpc": "2.0",
"result": {
"numFetched": "5",
"utxos": [
"0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765",
"0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a",
"0x0000731ce04b1feefa9f4291d869adc30a33463f315491e164d89be7d6d2d7890cfc00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21600dd3047",
"0x0000b462030cc4734f24c0bc224cf0d16ee452ea6b67615517caffead123ab4fbf1500000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c71b387e",
"0x000054f6826c39bc957c0c6d44b70f961a994898999179cc32d21eb09c1908d7167b00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f2166290e79d"
],
"endIndex": {
"address": "P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "kbUThAUfmBXUmRgTpgD6r3nLj7rJUGho6xyht5nouNNypH45j"
},
"encoding": "hex"
},
"id": 1
}
Since numFetched
is the same as limit
, we can tell that there may be more UTXOs that were not fetched. We call the method again, this time with startIndex
:
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getUTXOs",
"params" :{
"addresses":["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"limit":5,
"startIndex": {
"address": "P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "0x62fc816bb209857923770c286192ab1f9e3f11e4a7d4ba0943111c3bbfeb9e4a5ea72fae"
},
"encoding": "hex"
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
This gives response:
{
"jsonrpc": "2.0",
"result": {
"numFetched": "4",
"utxos": [
"0x000020e182dd51ee4dcd31909fddd75bb3438d9431f8e4efce86a88a684f5c7fa09300000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21662861d59",
"0x0000a71ba36c475c18eb65dc90f6e85c4fd4a462d51c5de3ac2cbddf47db4d99284e00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21665f6f83f",
"0x0000925424f61cb13e0fbdecc66e1270de68de9667b85baa3fdc84741d048daa69fa00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216afecf76a",
"0x000082f30327514f819da6009fad92b5dba24d27db01e29ad7541aa8e6b6b554615c00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216779c2d59"
],
"endIndex": {
"address": "P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "21jG2RfqyHUUgkTLe2tUp6ETGLriSDTW3th8JXFbPRNiSZ11jK"
},
"encoding": "hex"
},
"id": 1
}
Since numFetched
is less than limit
, we know that we are done fetching UTXOs and don’t need to call this method again.
Suppose we want to fetch the UTXOs exported from the X Chain to the P Chain in order to build an ImportTx. Then we need to call GetUTXOs with the sourceChain argument in order to retrieve the atomic UTXOs:
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getUTXOs",
"params" :{
"addresses":["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"sourceChain": "X",
"encoding": "hex"
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
This gives response:
{
"jsonrpc": "2.0",
"result": {
"numFetched": "1",
"utxos": [
"0x00001f989ffaf18a18a59bdfbf209342aa61c6a62a67e8639d02bb3c8ddab315c6fa0000000139c33a499ce4c33a3b09cdd2cfa01ae70dbf2d18b2d7d168524440e55d55008800000007000000746a528800000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29cd704fe76"
],
"endIndex": {
"address": "P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "S5UKgWoVpoGFyxfisebmmRf8WqC7ZwcmYwS7XaDVZqoaFcCwK"
},
"encoding": "hex"
},
"id": 1
}
platform.getValidatorsAt
Get the validators and their weights of a Subnet or the Primary Network at a given P-Chain height.
Signature
platform.getValidatorsAt(
{
height: int,
subnetID: string, // optional
}
)
height
is the P-Chain height to get the validator set at.subnetID
is the Subnet ID to get the validator set of. If not given, gets validator set of the Primary Network.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.getValidatorsAt",
"params": {
"height":1
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"validators": {
"NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg": 2000000000000000,
"NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu": 2000000000000000,
"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ": 2000000000000000,
"NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN": 2000000000000000,
"NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5": 2000000000000000
}
},
"id": 1
}
platform.importAVAX
Not recommended for use on Mainnet. See warning notice in Keystore API.
Complete a transfer of AVAX from the X-Chain, or C-Chain to the P-Chain.
Before this method is called, you must call the X-Chain’s avm.export
or C-Chain’s avax.export
method with assetID AVAX
to initiate the transfer.
Signature
platform.importAVAX(
{
to: string,
sourceChain: string,
from: []string, // optional
changeAddr: string, // optional
username: string,
password: string
}
) ->
{
tx: string,
changeAddr: string
}
to
is the ID of the address the AVAX is imported to. This must be the same as theto
argument in the corresponding call to the X-Chain’s or C-Chain'sexport
.sourceChain
is the chain the funds are coming from. Must be either"X"
or"C"
.from
are the addresses that you want to use for this operation. If omitted, uses any of your addresses as needed.changeAddr
is the address any change will be sent to. If omitted, change is sent to one of the addresses controlled by the user.username
is the user that controls from and change addresses.password
isusername
‘s password.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.importAVAX",
"params": {
"to": "P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"from": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u",
"username": "myUsername",
"password": "myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"txID": "P63NjowXaQJXt5cmspqdoD3VcuQdXUPM5eoZE2Vcg63aVEx8R",
"changeAddr": "P-metal103y30cxeulkjfe3kwfnpt432ylmnxux8r73r8u"
},
"id": 1
}
platform.importKey
Not recommended for use on Mainnet. See warning notice in Keystore API.
Give a user control over an address by providing the private key that controls the address.
Signature
platform.importKey({
username: string,
password: string,
privateKey:string
}) -> {address: string}
- Add
privateKey
tousername
‘s set of private keys.address
is the addressusername
now controls with the private key.
Example Call
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.importKey",
"params" :{
"username": "myUsername",
"password": "myPassword",
"privateKey": "PrivateKey-2w4XiXxPfQK4TypYqnohRL8DRNTz9cGiGmwQ1zmgEqD9c9KWLq"
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"address": "P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"
}
}
platform.issueTx
Issue a transaction to the Platform Chain.
Signature
platform.issueTx({
tx: string,
encoding: string, // optional
}) -> {txID: string}
tx
is the byte representation of a transaction.encoding
specifies the encoding format for the transaction bytes. Can only behex
when a value is provided.txID
is the transaction’s ID.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.issueTx",
"params": {
"tx":"0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730",
"encoding": "hex"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"txID": "G3BuH6ytQ2averrLxJJugjWZHTRubzCrUZEXoheG5JMqL5ccY"
},
"id": 1
}
platform.listAddresses
Not recommended for use on Mainnet. See warning notice in Keystore API.
List addresses controlled by the given user.
Signature
platform.listAddresses({
username: string,
password: string
}) -> {addresses: []string}
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.listAddresses",
"params": {
"username":"myUsername",
"password":"myPassword"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"addresses": ["P-metal18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"]
},
"id": 1
}
platform.sampleValidators
Sample validators from the specified Subnet.
Signature
platform.sampleValidators(
{
size: int,
subnetID: string, // optional
}
) ->
{
validators: []string
}
size
is the number of validators to sample.subnetID
is the Subnet to sampled from. If omitted, defaults to the Primary Network.- Each element of
validators
is the ID of a validator.
Example Call
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.sampleValidators",
"params" :{
"size":2
}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"validators": [
"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ",
"NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN"
]
}
}
platform.validatedBy
Get the Subnet that validates a given blockchain.
Signature
platform.validatedBy(
{
blockchainID: string
}
) -> {subnetID: string}
blockchainID
is the blockchain’s ID.subnetID
is the ID of the Subnet that validates the blockchain.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.validatedBy",
"params": {
"blockchainID": "KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r"
},
"id": 1
}
platform.validates
Get the IDs of the blockchains a Subnet validates.
Signature
platform.validates(
{
subnetID: string
}
) -> {blockchainIDs: []string}
subnetID
is the Subnet’s ID.- Each element of
blockchainIDs
is the ID of a blockchain the Subnet validates.
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "platform.validates",
"params": {
"subnetID":"2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r"
},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P
Example Response
{
"jsonrpc": "2.0",
"result": {
"blockchainIDs": [
"KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN",
"2TtHFqEAAJ6b33dromYMqfgavGPF3iCpdG3hwNMiart2aB5QHi"
]
},
"id": 1
}