Direct transfer of tokens
Intermediate
Tutorial
Overview
The request type that is used for making direct transfers is TRANSFER
. In the simplest form it consists of two operations, one for the debit operation and one for the credit operation.
You do not have to specify the FEE
operation, although the FEE
of the ICRC-1 ledger will be deducted automatically by Rosetta.
The call may include a FEE
operation to not overlook unexpected debit operations.
Prerequisites
- Make sure you are familiar with the flow of operations for Rosetta.
Transfer tokens
An example of the minimum set of operations that is sent to the construction/payloads
endpoint can be found below.
In this example, you are sending 10 e8 ckBTC from principal iowfl-yzooa-br3dt-77erl-nlm7f-kplhq-php75-hw3an-aeqn2-swh4t-3qe
to principal xmiu5-jqaaa-aaaag-qbz7q-cai
.
curl --location '0.0.0.0:8082/construction/payloads' --header 'Content-Type: application/json' --data
'{
"network_identifier": {
"blockchain": "Internet Computer",
"network": "mxzaz-hqaaa-aaaar-qaada-cai"
},
"public_keys": [
{
"hex_bytes": "047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c757367",
"curve_type": "secp256k1"
}
],
"operations": [
{
"operation_identifier": {
"index": 0
},
"type": "TRANSFER",
"account": {
"address": "iowfl-yzooa-br3dt-77erl-nlm7f-kplhq-php75-hw3an-aeqn2-swh4t-3qe",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "-10",
"currency": {
"symbol": "8",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 1
},
"type": "TRANSFER",
"account": {
"address": "xmiu5-jqaaa-aaaag-qbz7q-cai",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "10",
"currency": {
"symbol": "8",
"decimals": 8
}
}
}
],
"metadata": null
}'