For AI agents: an LLM-friendly Markdown version of every page is available by appending .md to its URL or by sending an Accept: text/markdown request header. The full documentation index is at https://www.ankr.com/docs/llms.txt
Skip to main content

Avalanche — P-Chain methods, C-Chain methods, X-Chain methods (1/2)

API reference for Avalanche. All methods ->

Part 1 of 2: 1 · 2

platform.getUTXOs

Retrieves the UTXOs that reference a given set of addresses.

Parameters

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,
}

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: a list of addresses to retrieve the info for.
    • limit: the max number of UTXOs to be returned; if limit is omitted or greater than 1024, it is set to 1024.
    • encoding specifies the format for the returned UTXOs; can only be hex when a value is provided.

Response parameters:

  • utxos is a list of UTXOs such that each UTXO references at least one address in addresses.
  • At most limit UTXOs are returned. If limit 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 of endIndex as startIndex in the next call.
  • If startIndex is omitted, will fetch all UTXOs up to limit.
  • When using pagination (that is 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 be hex when a value is provided.

Request example

Suppose we want all UTXOs that reference at least one of P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5 and P-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6.

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.getUTXOs",
"params" :{
"addresses":["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "P-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6"],
"limit":5,
"encoding": "hex"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"numFetched": "5",
"utxos": [
"0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765",
"0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a",
"0x0000731ce04b1feefa9f4291d869adc30a33463f315491e164d89be7d6d2d7890cfc00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21600dd3047",
"0x0000b462030cc4734f24c0bc224cf0d16ee452ea6b67615517caffead123ab4fbf1500000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c71b387e",
"0x000054f6826c39bc957c0c6d44b70f961a994898999179cc32d21eb09c1908d7167b00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f2166290e79d"
],
"endIndex": {
"address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "kbUThAUfmBXUmRgTpgD6r3nLj7rJUGho6xyht5nouNNypH45j"
},
"encoding": "hex"
},
"id": 1
}

Request example

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 'https://rpc.ankr.com/avalanche-p/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getUTXOs",
"params" :{
"addresses":["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"limit":5,
"startIndex": {
"address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "0x62fc816bb209857923770c286192ab1f9e3f11e4a7d4ba0943111c3bbfeb9e4a5ea72fae"
},
"encoding": "hex"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"numFetched": "4",
"utxos": [
"0x000020e182dd51ee4dcd31909fddd75bb3438d9431f8e4efce86a88a684f5c7fa09300000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21662861d59",
"0x0000a71ba36c475c18eb65dc90f6e85c4fd4a462d51c5de3ac2cbddf47db4d99284e00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21665f6f83f",
"0x0000925424f61cb13e0fbdecc66e1270de68de9667b85baa3fdc84741d048daa69fa00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216afecf76a",
"0x000082f30327514f819da6009fad92b5dba24d27db01e29ad7541aa8e6b6b554615c00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216779c2d59"
],
"endIndex": {
"address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "21jG2RfqyHUUgkTLe2tUp6ETGLriSDTW3th8JXFbPRNiSZ11jK"
},
"encoding": "hex"
},
"id": 1
}

platform.getValidatorsAt

Retrieves the validators and their weights of a Subnet or the Primary Network at a given P-Chain height.

Parameters

Signature:

platform.getValidatorsAt(
{
height: int,
subnetID: string, // optional
}
)

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):

    • height: the P-Chain height to get the validator set at.
    • subnetID: the Subnet ID to get the validator set of; if not given, gets validator set of the Primary Network.

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.getValidatorsAt",
"params" :{
"height": 1,
"subnetID": "11111111111111111111111111111111LpoYY"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"validators": {
"NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg": 2000000000000000,
"NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu": 2000000000000000,
"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ": 2000000000000000,
"NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN": 2000000000000000,
"NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5": 2000000000000000
}
},
"id": 1
}

platform.issueTx

Issues a transaction to the Platform Chain.

Parameters

Signature:

platform.issueTx({
tx: string,
encoding: string, // optional
}) -> {txID: 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):

    • tx: the byte representation of a transaction.
    • encoding: specifies the encoding format for the transaction bytes; can only be hex when a value is provided.

Response parameters:

  • txID: the transaction’s 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.issueTx",
"params" :{
"tx": "0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730",
"encoding": "hex"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"txID": "G3BuH6ytQ2averrLxJJugjWZHTRubzCrUZEXoheG5JMqL5ccY"
},
"id": 1
}

platform.sampleValidators

Retrieves the validators from the specified Subnet.

Parameters

Signature:

platform.sampleValidators(
{
size: int,
subnetID: string, // optional
}
) ->
{
validators: []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):

    • size: the number of validators to sample.
    • subnetID: the Subnet to sampled from; if omitted, defaults to the Primary Network.

Response parameters:

  • validators: each element of validators is the ID of a validator.

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.sampleValidators",
"params" :{
"size":2
}
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"validators": [
"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ",
"NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN"
]
}
}

platform.validatedBy

Retrieves the Subnet that validates a given blockchain.

Parameters

Signature:

platform.validatedBy(
{
blockchainID: string
}
) -> {subnetID: 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: the blockchain’s ID.

Response parameters:

  • subnetID the ID of the Subnet that validates the blockchain.

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.validatedBy",
"params" : {
"blockchainID": "DKtd96mRjG1fgfL1Bcr9gppJaPxi9345iLR3W9ZZwq8ZChY9A"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r"
},
"id": 1
}

platform.validates

Retrieves the IDs of the blockchains a Subnet validates.

Parameters

Signature:

platform.validates(
{
subnetID: string
}
) -> {blockchainIDs: []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’s ID.

Response parameters:

  • blockchainIDs: each element of blockchainIDs is the ID of a blockchain the Subnet validates.

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.validates",
"params" : {
"subnetID":"4vczxAbLhSpzypadHFEfY8Kn2kibhcZLQgoX9A34rAnADyXnp"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"blockchainIDs": [
"KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN",
"2TtHFqEAAJ6b33dromYMqfgavGPF3iCpdG3hwNMiart2aB5QHi"
]
},
"id": 1
}

C-Chain methods


avax.getAtomicTx

Retrieves a transaction by its ID.

Optional encoding parameter to specify the format for the returned transaction. Can only be hex when a value is provided.

Parameters

Signature:

avax.getAtomicTx({
txID: string,
encoding: string, //optional
}) -> {
tx: string,
encoding: string,
blockHeight: 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 transaction ID in cb58 format.
    • encoding: the encoding format to use; can only be hex when a value is provided.

Response parameters:

  • tx: the transaction encoded to encoding.
  • encoding: the encoding.
  • blockHeight: the height of the block at which the transaction was included in.

Request example

curl -X POST 'https://rpc.ankr.com/avalanche-c/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avax.getAtomicTx",
"params" : {
"txID":"2GD5SRYJQr2kw5jE73trBFiAgVQyrCaeg223TaTyJFYXf2kPty",
"encoding": "hex"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"tx": "0x000000000000000030399d0775f450604bd2fbc49ce0c5c1c6dfeb2dc2acb8c92c26eeae6e6df4502b19d891ad56056d9c01f18f43f58b5c784ad07a4a49cf3d1f11623804b5cba2c6bf000000018212d6807a0ec9c1b26321418fe7a548180b5be728ce53fe7e98ab5755ed316100000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000005000003a352a382400000000100000000000000018db97c7cece249c2b98bdc0226cc4c2a57bf52fc000003a3529edd17dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000010000000900000001ead19377f015422fbb8731204fcf6d6879dd05146c2d5b5594e2fea2cb420b2f40bd457b71e279e547790b28fe5482f278c76cf39b2dce5c2e6c53352fe6827d002cc7d20d",
"encoding": "hex",
"blockHeight": "1"
},
"id": 1
}

avax.getAtomicTxStatus

Retrieves the status of an atomic transaction sent to the network.

Parameters

Signature:

avax.getAtomicTxStatus({txID: string}) -> {
status: string,
blockHeight: string // returned when status is Accepted
}

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 transaction ID in cb58 format.

Response parameters:

  • status: either of the following items:
    • Accepted: the transaction is (or will be) accepted by every node. Check the blockHeight property.
    • Processing: the transaction is being voted on by this node.
    • Dropped: the transaction was dropped by this node because it thought the transaction invalid.
    • Unknown: the transaction hasn’t been seen by this node.

Response example

curl -X POST 'https://rpc.ankr.com/avalanche-c/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avax.getAtomicTxStatus",
"params" : {
"txID":"2QouvFWUbjuySRxeX5xMbNCuAaKWfbk5FeEa2JmoF85RKLk2dD"
}
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"status": "Accepted",
"blockHeight": "1"
}
}

avax.getUTXOs

Retrieves the UTXOs that reference a given address.

Parameters

Signature:

avax.getUTXOs(
{
addresses: string,
limit: int, //optional
startIndex: { //optional
address: string,
utxo: string
},
sourceChain: string,
encoding: string, //optional
},
) ->
{
numFetched: int,
utxos: []string,
endIndex: {
address: string,
utxo: 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):

    • utxos: a list of UTXOs such that each UTXO references at least one address in addresses.
    • limit: the max number of UTXOs to be returned; if limit 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 of endIndex as startIndex in the next call.
    • If startIndex is omitted, will fetch all UTXOs up to limit.
    • When using pagination (that is 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 sets the format for the returned UTXOs; can only be hex when a value is provided.

Request example

Suppose we want all UTXOs that reference at least one of C-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5.

curl -X POST 'https://rpc.ankr.com/avalanche-c/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avax.getUTXOs",
"params" : {
"addresses":["C-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"],
"sourceChain": "X",
"startIndex": {
"address": "C-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "22RXW7SWjBrrxu2vzDkd8uza7fuEmNpgbj58CxBob9UbP37HSB"
},
"encoding": "hex"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"numFetched": "3",
"utxos": [
"0x0000a799e7448acf74ca9223159a04f93b948f99cf28509f908839532b2f85baffc300000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c22d23171",
"0x00006385c683d43bdbe754c224be36c5004ea7ce49c0849cadeaea6af93dae18cc7700000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29cb81cc877",
"0x000038137283c94582351b86c3e90808312636769e3f5c14fbf1152d6634f770695c00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c7412490e"
],
"endIndex": {
"address": "C-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"utxo": "0x9333ef8a05f26acf2d8766f94723f749870fa2ca80c19c33cc945d79013d7c50fd023beb"
},
"encoding": "hex"
},
"id": 1
}

avax.issueTx

Sends a signed transaction to the network.

encoding specifies the format of the signed transaction. Can only be hex when a value is provided.

Parameters

Signature:

avax.issueTx({
tx: string,
encoding: string, //optional
}) -> {
txID: 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):

    • tx: a transaction.
    • encoding: the encoding format to use; can only be hex when a value is provided.

Request example

curl -X POST 'https://rpc.ankr.com/avalanche-c/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avax.issueTx",
"params" : {
"tx": "0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730",
"encoding": "hex"
}
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"txID": "NUPLwbt2hsYxpQg4H2o451hmTWQ4JZx2zMzM4SinwtHgAdX1JLPHXvWSXEnpecStLj"
}
}

X-Chain methods

  • avm.buildGenesis — creates the byte representation of the given JSON representation of the Virtual Machine's genesis state.
  • avm.getAddressTxs — retrieves all transactions that change the balance of the given address.
  • avm.getAllBalances — retrieves the balances of all assets controlled by a given address.
  • avm.getAssetDescription — retrieves information about an asset.
  • avm.getBalance — retrieves the balance of an asset controlled by a given address.
  • avm.getBlock — retrieves the block with the given ID.
  • avm.getBlockByHeight — retrieves a block at the given height.
  • avm.getHeight — retrieves the height of the last accepted block.
  • avm.getTx — retrieves the specified transaction.
  • avm.getTxStatus — retrieves the status of a transaction sent to the network.
  • avm.getUTXOs — retrieves the UTXOs that reference a given address.
  • avm.issueTx — sends a signed transaction to the network.

avm.buildGenesis

Creates the byte representation of the given JSON representation of the Virtual Machine's genesis state.

Parameters

Signature:

avm.buildGenesis({
networkID: int,
genesisData: JSON,
encoding: string, //optional
}) -> {
bytes: 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):

    • networkID: a network ID.
    • encoding: the encoding format to use for arbitrary bytes, that is the genesis bytes that are returned; can only be hex when a value is provided.
    • genesisData: has the following structure:
{
"genesisData" :
{
"assetAlias1": { // Each object defines an asset
"name": "human readable name",
"symbol":"AVAL", // Symbol is between 0 and 4 characters
"initialState": {
"fixedCap" : [ // Choose the asset type.
{ // Can be "fixedCap", "variableCap", "limitedTransfer", "nonFungible"
"amount":1000, // At genesis, address A has
"address":"A" // 1000 units of asset
},
{
"amount":5000, // At genesis, address B has
"address":"B" // 1000 units of asset
},
... // Can have many initial holders
]
}
},
"assetAliasCanBeAnythingUnique": { // Asset alias can be used in place of assetID in calls
"name": "human readable name", // names need not be unique
"symbol": "AVAL", // symbols need not be unique
"initialState": {
"variableCap" : [ // No units of the asset exist at genesis
{
"minters": [ // The signature of A or B can mint more of
"A", // the asset.
"B"
],
"threshold":1
},
{
"minters": [ // The signatures of 2 of A, B and C can mint
"A", // more of the asset
"B",
"C"
],
"threshold":2
},
... // Can have many minter sets
]
}
},
... // Can list more assets
}
}

Request example

curl -X POST 'https://rpc.ankr.com/avalanche-x/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avm.buildGenesis",
"params" : {
"networkId": 16,
"genesisData": {
"asset1": {
"name": "myFixedCapAsset",
"symbol":"MFCA",
"initialState": {
"fixedCap" : [
{
"amount":100000,
"address": "avax13ery2kvdrkd2nkquvs892gl8hg7mq4a6ufnrn6"
},
{
"amount":100000,
"address": "avax1rvks3vpe4cm9yc0rrk8d5855nd6yxxutfc2h2r"
},
{
"amount":50000,
"address": "avax1ntj922dj4crc4pre4e0xt3dyj0t5rsw9uw0tus"
},
{
"amount":50000,
"address": "avax1yk0xzmqyyaxn26sqceuky2tc2fh2q327vcwvda"
}
]
}
},
"asset2": {
"name": "myVarCapAsset",
"symbol":"MVCA",
"initialState": {
"variableCap" : [
{
"minters": [
"avax1kcfg6avc94ct3qh2mtdg47thsk8nrflnrgwjqr",
"avax14e2s22wxvf3c7309txxpqs0qe9tjwwtk0dme8e"
],
"threshold":1
},
{
"minters": [
"avax1y8pveyn82gjyqr7kqzp72pqym6xlch9gt5grck",
"avax1c5cmm0gem70rd8dcnpel63apzfnfxye9kd4wwe",
"avax12euam2lwtwa8apvfdl700ckhg86euag2hlhmyw"
],
"threshold":2
}
]
}
}
},
"encoding": "hex"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"bytes": "0x0000000000010006617373657431000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f6d794669786564436170417373657400044d464341000000000100000000000000010000000700000000000186a10000000000000000000000010000000152b219bc1b9ab0a9f2e3f9216e4460bd5db8d153bfa57c3c",
"encoding": "hex"
},
"id": 1
}

X-Chain methods

avm.getAddressTxs

Retrieves all transactions that change the balance of the given address.

A transaction is said to change an address's balance if either is true:

  • A UTXO that the transaction consumes was at least partially owned by the address.
  • A UTXO that the transaction produces is at least partially owned by the address.

Parameters

Signature:

avm.getAddressTxs({
address: string,
cursor: uint64, // optional, leave empty to get the first page
assetID: string,
pageSize: uint64 // optional, defaults to 1024
}) -> {
txIDs: []string,
cursor: 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):

    • address: the address for which we're fetching related transactions.
    • assetID: only return transactions that changed the balance of this asset. Must be an ID or an alias for an asset.
    • pageSize: number of items to return per page. Optional. Defaults to 1024.

Response parameters:

  • txIDs: a list of transaction IDs that affected the balance of this address.
  • cursor: a page number or offset; use this in request to get the next page.

Request example

curl -X POST 'https://rpc.ankr.com/avalanche-x/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avm.getAddressTxs",
"params" : {
"address":"X-avax1dp6707ka34puejwg7ntnenxry98h37yvsqsm7f",
"assetID":"AVAX",
"pageSize":20
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"txIDs": ["SsJF7KKwxiUJkczygwmgLqo3XVRotmpKP8rMp74cpLuNLfwf6"],
"cursor": "1"
},
"id": 1
}

avm.getAllBalances

Retrieves the balances of all assets controlled by a given address.

Parameters

Signature:

avm.getAllBalances({address:string}) -> {
balances: []{
asset: 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: an address to retrieves the balances for.

Request example

curl -X POST 'https://rpc.ankr.com/avalanche-x/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avm.getAllBalances",
"params" : {
"address":"X-avax1dp6707ka34puejwg7ntnenxry98h37yvsqsm7f"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"balances": [
{
"asset": "AVAX",
"balance": "102"
},
{
"asset": "2sdnziCz37Jov3QSNMXcFRGFJ1tgauaj6L7qfk7yUcRPfQMC79",
"balance": "10000"
}
]
},
"id": 1
}

avm.getAssetDescription

Retrieves information about an asset.

Parameters

Signature:

avm.getAssetDescription({assetID: string}) -> {
assetId: string,
name: string,
symbol: string,
denomination: 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):

    • assetID: the id of the asset for which the information is requested.

Response parameters:

  • name: the asset’s human-readable, not necessarily unique name.
  • symbol: the asset’s symbol.
  • denomination: determines how balances of this asset are displayed by user interfaces. If denomination is 0, 100 units of this asset are displayed as 100. If denomination is 1, 100 units of this asset are displayed as 10.0. If denomination is 2, 100 units of this asset are displays as .100, etc.

Request example

curl -X POST 'https://rpc.ankr.com/avalanche-x/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avm.getAssetDescription",
"params" : {
"assetID" :"FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z"
}
}'

Response example

{
"jsonrpc": "2.0",
"result": {
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
"name": "Avalanche",
"symbol": "AVAX",
"denomination": "9"
},
"id": 1
}`

avm.getBalance

Retrieves the balance of an asset controlled by a given address.

Parameters

Signature:

avm.getBalance({
address: string,
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: an owner of the asset.
    • assetID: an ID of the asset for which the balance is requested.

Request example

curl -X POST 'https://rpc.ankr.com/avalanche-x/YOUR_ANKR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"id" :1,
"method" :"avm.getBalance",
"params" : {
"address":"X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5",
"assetID": "2pYGetDWyKdHxpFxh2LHeoLNCH6H5vxxCxHQtFnnFaYxLsqtHC"
}
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"balance": "299999999999900",
"utxoIDs": [
{
"txID": "WPQdyLNqHfiEKp4zcCpayRHYDVYuh1hqs9c1RqgZXS4VPgdvo",
"outputIndex": 1
}
]
}
}