Solana - Transferring Tokens
This article covers what steps you need to follow to transfer Solana Tokens (Spl).
The following steps and examples are based on Solana Devnet.
Steps
Step_1: Gather the transfer parameter details
- Confirm the "Token contract address" and the "digits" (decimals). See Example Token
- Confirm the Sender's blockchain address.
- Confirm the PrivateKey to sign the transaction matches with the Sender's blockchain address.
- Confirm the Recipient blockchain address.
Step_2: Check the Native asset balance of an address
Token transfer gas fees are paid with Native chain assets i.e. SOL. Ensure the Sender's blockchain address has enough Native assets (SOL) to cover the gas fees of the transfer.
Example request:
- Returns address balance in Native assets
curl --location 'https://api.tatum.io/v3/solana/account/balance/BWmkpRBdW6EvQcsQLEaAbRMvn3VxXxo83su2HZT3fPqh' \
--header 'x-api-key: {YOUR_API_KEY}'
//Response:
{
"balance": "4.99444484"
}
Token transfers are paid with Native chain assets. That's now blockchain transactions work. Tatum has no say over this.
Step_3: Transfer Solana tokens (Spl)
Request Example:
- Returns the hash (ID) of the transfer transaction
curl --location 'https://api.tatum.io/v3/blockchain/token/transaction' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
"chain": "SOL",
"from": "BWmkpRBdW6EvQcsQLEaAbRMvn3VxXxo83su2HZT3fPqh",
"to": "3K7nHLHsamvgZ7qNiCLxgzruPzJ12BDZmjTG7rUn8Yrh",
"contractAddress": "HCz6wUe9r9J2BFNT16x7EJjYH6SVjZEdxbe2vQghWubM",
"amount": "50",
"digits": 6,
"fromPrivateKey": "####"
}'
//Response:
{
"txId": {
"txId": "3TtUvEyLcTvaPpHEQFMBffHYs5dXyJ5FxPByeD4Eh6bHStJqY2pWwNFzwMLumi9sVSdXXMwy7xT57QwVGaAfw75S"
}
}
Step_4: Get the details of a transaction
Request example:
curl --location 'https://api.tatum.io/v3/solana/transaction/3TtUvEyLcTvaPpHEQFMBffHYs5dXyJ5FxPByeD4Eh6bHStJqY2pWwNFzwMLumi9sVSdXXMwy7xT57QwVGaAfw75S' \
--header 'x-api-key: {YOUR_API_KEY}'
{
"blockTime": 1719350231,
"meta": {
"computeUnitsConsumed": 26839,
"err": null,
"fee": 5000,
"innerInstructions": [
{
"index": 0,
"instructions": [
{
"accounts": [
6
],
"data": "84eT",
"programIdIndex": 8,
"stackHeight": 2
},
{
"accounts": [
0,
2
],
"data": "11119os1e9qSs2u7TsThXqkBSRVFxhmYaFKFZ1waB2X7armDmvK3p5GmLdUxYdg3h7QSrL",
"programIdIndex": 3,
"stackHeight": 2
},
{
"accounts": [
2
],
"data": "P",
"programIdIndex": 8,
"stackHeight": 2
},
{
"accounts": [
2,
6
],
"data": "6PSpTDXpfsdCWpbvtoMYJAyJHtsspRvVGUed7cSAbRhHf",
"programIdIndex": 8,
"stackHeight": 2
}
]
}
],
"loadedAddresses": {
"readonly": [],
"writable": []
},
"logMessages": [
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]",
"Program log: Create",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: GetAccountDataSize",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1622 of 392908 compute units",
"Program return: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA pQAAAAAAAAA=",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program 11111111111111111111111111111111 invoke [2]",
"Program 11111111111111111111111111111111 success",
"Program log: Initialize the associated token account",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: InitializeImmutableOwner",
"Program log: Please upgrade to SPL Token 2022 for immutable owner support",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1405 of 386268 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: InitializeAccount3",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4241 of 382384 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 22195 of 400000 compute units",
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]",
"Program log: Instruction: Transfer",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4644 of 377805 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success"
],
"postBalances": [
4994444840,
2039280,
2039280,
1,
0,
731913600,
1461600,
1009200,
934087680
],
"postTokenBalances": [
{
"accountIndex": 1,
"mint": "HCz6wUe9r9J2BFNT16x7EJjYH6SVjZEdxbe2vQghWubM",
"owner": "BWmkpRBdW6EvQcsQLEaAbRMvn3VxXxo83su2HZT3fPqh",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "199950000000",
"decimals": 6,
"uiAmount": 199950,
"uiAmountString": "199950"
}
},
{
"accountIndex": 2,
"mint": "HCz6wUe9r9J2BFNT16x7EJjYH6SVjZEdxbe2vQghWubM",
"owner": "3K7nHLHsamvgZ7qNiCLxgzruPzJ12BDZmjTG7rUn8Yrh",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "50000000",
"decimals": 6,
"uiAmount": 50,
"uiAmountString": "50"
}
}
],
"preBalances": [
4996489120,
2039280,
0,
1,
0,
731913600,
1461600,
1009200,
934087680
],
"preTokenBalances": [
{
"accountIndex": 1,
"mint": "HCz6wUe9r9J2BFNT16x7EJjYH6SVjZEdxbe2vQghWubM",
"owner": "BWmkpRBdW6EvQcsQLEaAbRMvn3VxXxo83su2HZT3fPqh",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "200000000000",
"decimals": 6,
"uiAmount": 200000,
"uiAmountString": "200000"
}
}
],
"rewards": [],
"status": {
"Ok": null
}
},
"slot": 308182420,
"transaction": {
"message": {
"header": {
"numReadonlySignedAccounts": 0,
"numReadonlyUnsignedAccounts": 6,
"numRequiredSignatures": 1
},
"accountKeys": [
"BWmkpRBdW6EvQcsQLEaAbRMvn3VxXxo83su2HZT3fPqh",
"2Hq23kEsc5Vm9vYaC7h293v5HhRTFLahbjwbjq6BrXSE",
"HJEjGJWYs5CMbPg3HTwUc7ZJhU7s4orZ1XfehkSNk88G",
"11111111111111111111111111111111",
"3K7nHLHsamvgZ7qNiCLxgzruPzJ12BDZmjTG7rUn8Yrh",
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
"HCz6wUe9r9J2BFNT16x7EJjYH6SVjZEdxbe2vQghWubM",
"SysvarRent111111111111111111111111111111111",
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
],
"recentBlockhash": "HJHb2qJnz6X7x6kB9mZvb95ugn9jZKv51bLi6uVnFL4X",
"instructions": [
{
"accounts": [
0,
2,
4,
6,
3,
8,
7
],
"data": "",
"programIdIndex": 5,
"stackHeight": null
},
{
"accounts": [
1,
2,
0
],
"data": "3b2TMHxMePoM",
"programIdIndex": 8,
"stackHeight": null
}
],
"indexToProgramIds": {}
},
"signatures": [
"3TtUvEyLcTvaPpHEQFMBffHYs5dXyJ5FxPByeD4Eh6bHStJqY2pWwNFzwMLumi9sVSdXXMwy7xT57QwVGaAfw75S"
]
},
"version": "legacy"
}
Good to Know
- Be mindful of Tatum's derivation path. Find additional information in the following article.
- Familiarize yourself with the Safety & Security Basics in the following article.
Error Troubleshooting
Updated 4 months ago