This page is an overview of the X-Chain API associated with AvalancheGo.
Tip
This page was generated by a plugin that directly references this file in the AvalancheGo GitHub repository.
The X-Chain,
Avalanche's native platform for creating and trading assets, is an instance of the Avalanche Virtual
Machine (AVM). This API allows clients to create and trade assets on the X-Chain and other instances
of the AVM.
This call is made to the AVM's static API endpoint:
/ext/vm/avm
Note: addresses should not include a chain prefix (that is X-) in calls to the static API endpoint
because these prefixes refer to a specific chain.
Signature:
Encoding specifies 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.
Not recommended for use on Mainnet. See warning notice in Keystore API.
Create a new fixed-cap, fungible asset. A quantity of it is created at initialization and then no
more is ever created. The asset can be sent with avm.send.
Signature:
name is a human-readable name for the asset. Not necessarily unique.
symbol is a shorthand symbol for the asset. Between 0 and 4 characters. Not necessarily unique.
May be omitted.
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
displayed as 1.00, etc. Defaults to 0.
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 and password denote the user paying the transaction fee.
Each element in initialHolders specifies that address holds amount units of the asset at
genesis.
Not recommended for use on Mainnet. See warning notice in Keystore API.
Create a new non-fungible asset. No units of the asset exist at initialization. Minters can mint
units of this asset using avm.mintNFT.
Signature:
name is a human-readable name for the asset. Not necessarily unique.
symbol is a shorthand symbol for the asset. Between 0 and 4 characters. Not necessarily unique.
May be omitted.
minterSets is a list where each element specifies that threshold of the addresses in minters
may together mint more of the asset by signing a minting transaction.
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 pays the transaction fee.
assetID is the ID of the new asset.
changeAddr in the result is the address where any change was sent.
Not recommended for use on Mainnet. See warning notice in Keystore API.
Create a new variable-cap, fungible asset. No units of the asset exist at initialization. Minters
can mint units of this asset using avm.mint.
Signature:
name is a human-readable name for the asset. Not necessarily unique.
symbol is a shorthand symbol for the asset. Between 0 and 4 characters. Not necessarily unique.
May be omitted.
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.
minterSets is a list where each element specifies that threshold of the addresses in minters
may together mint more of the asset by signing a minting transaction.
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 pays the transaction fee.
assetID is the ID of the new asset.
changeAddr in the result is the address where any change was sent.
assetID is the id of the asset for which the information is requested.
name is the asset's human-readable, not necessarily unique name.
symbol is 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.
Note
The AssetID for AVAX differs depending on the network you are on.
Returns the specified transaction. The encoding parameter sets the format of the returned
transaction. Can be either "hex" or "json". Defaults to "hex".
Signature:
Example Call:
Example Response:
Where:
credentials is a list of this transaction's credentials. Each credential proves that this
transaction's creator is allowed to consume one of this transaction's inputs. Each credential is a
list of signatures.
unsignedTx is the non-signature portion of the transaction.
networkID is the ID of the network this transaction happened on. (Avalanche Mainnet is 1.)
blockchainID is the ID of the blockchain this transaction happened on. (Avalanche Mainnet
X-Chain is 2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM.)
Each element of outputs is an output (UTXO) of this transaction that is not being exported to
another chain.
Each element of inputs is an input of this transaction which has not been imported from another
chain.
Import Transactions have additional fields sourceChain and importedInputs, which specify the
blockchain ID that assets are being imported from, and the inputs that are being imported.
Export Transactions have additional fields destinationChain and exportedOutputs, which specify
the blockchain ID that assets are being exported to, and the UTXOs that are being exported.
An output contains:
assetID: The ID of the asset being transferred. (The Mainnet Avax ID is
FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z.)
fxID: The ID of the FX this output uses.
output: The FX-specific contents of this output.
Most outputs use the secp256k1 FX, look like this:
The above output can be consumed after Unix time locktime by a transaction that has signatures
from threshold of the addresses in addresses.
Gets the UTXOs that reference a given address. If sourceChain is specified, then it will retrieve
the atomic UTXOs exported from that chain to the X Chain.
Signature:
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 (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.
Suppose we want all UTXOs that reference at least one of
X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5 and X-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6.
This gives response:
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:
This gives response:
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 P Chain to the X Chain in order to build an
ImportTx. Then we need to call GetUTXOs with the sourceChain argument in order to retrieve the
atomic UTXOs:
Not recommended for use on Mainnet. See warning notice in Keystore API.
Finalize a transfer of an asset from the P-Chain or C-Chain to the X-Chain.
Signature:
to is the address the AVAX is sent to. This must be the same as the to argument in the
corresponding call to the P-Chain's exportAVAX or C-Chain's export.
sourceChain is the ID or alias of the chain the AVAX is being imported from. To import funds
from the C-Chain, use "C".
username is the user that controls to.
txID is the ID of the newly created atomic transaction.
amount units of assetID will be created and controlled by address 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 that pays the transaction fee. username must hold keys giving it
permission to mint more of this asset. That is, it must control at least threshold keys for one
of the minter sets.
txID is this transaction's ID.
changeAddr in the result is the address where any change was sent.
assetID is the assetID of the newly created NFT asset.
payload is an arbitrary payload of up to 1024 bytes. Its encoding format is specified by the
encoding argument.
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. username must hold keys giving it
permission to mint more of this asset. That is, it must control at least threshold keys for one
of the minter sets.
txID is this transaction's ID.
changeAddr in the result is the address where any change was sent.
encoding is the encoding format to use for the payload argument. Can only be hex when a value
is provided.
Not recommended for use on Mainnet. See warning notice in Keystore API.
Send a quantity of an asset to an address.
Signature:
Sends amount units of asset with ID assetID to address to. amount is denominated in the
smallest increment of the asset. For AVAX this is 1 nAVAX (one billionth of 1 AVAX.)
to is the X-Chain address the asset is sent 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.
You can attach a memo, whose length can be up to 256 bytes.
The asset is sent from addresses controlled by user username. (Of course, that user will need to
hold at least the balance of the asset being sent.)
Not recommended for use on Mainnet. See warning notice in Keystore API.
Send a non-fungible token.
Signature:
assetID is the asset ID of the NFT being sent.
groupID is the NFT group from which to send the NFT. NFT creation allows multiple groups under
each NFT ID. You can issue multiple NFTs to each group.
to is the X-Chain address the NFT is sent 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.
The asset is sent from addresses controlled by user username. (Of course, that user will need to
hold at least the balance of the NFT being sent.)
Send a signed transaction to the network and assume the TX will be accepted. encoding specifies
the format of the signed transaction. Can only be hex when a value is provided.
Sends amount units of asset with ID assetID to address to. amount is denominated in the
smallest increment of the asset. For AVAX this is 1 nAVAX (one billionth of 1 AVAX.)
to is the X-Chain address the asset is sent 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.
You can attach a memo, whose length can be up to 256 bytes.
The asset is sent from addresses controlled by user username. (Of course, that user will need to
hold at least the balance of the asset being sent.)
Not recommended for use on Mainnet. See warning notice in Keystore API.
Send multiple transfers of amount of assetID, to a specified address from a list of owned of
addresses and assume the TX will be accepted so that future calls can use the modified UTXO set.
maxElements - number of elements in filter must be > 0 collisionProb - allowed collision probability must be > 0 and <= 1
AddAddresses
add an address to the set
{"addAddresses":{"addresses":\["X-fuji..."\]}}
addresses - list of addresses to match
Calling NewSet or NewBloom resets the filter, and must be followed with AddAddresses.
AddAddresses can be called multiple times.
Set details:
NewSet performs absolute address matches, if the address is in the set you will be sent the
transaction.
NewBloomBloom filtering can produce false
positives, but can allow a greater number of addresses to be filtered. If the addresses is in the
filter, you will be sent the transaction.