Regular token transfers
This document details how to transfer ICP using the Rosetta Construction API. See Construction API Overview for a high-level overview of the transaction flow.
Transfer operations
A transaction that transfers amount T
from address A
to address B
must contain three operations:
-
An operation of type
TRANSACTION
applied to addressA
with the amount of-T
. -
An operation of type
TRANSACTION
applied to addressB
with the amount ofT
. -
An operation of type
FEE
applied to addressA
with the amount suggested by the/construction/metadata
endpoint (seesuggested_fee
field of the ConstructionMetadataResponse type).
The order of operations within a transaction is irrelevant.
Multiple transfers within a single transaction are not allowed. The outcome of such a transaction is unspecified.
Preconditions:
-
Address
A
holds at leastT
+suggested_fee
ICP. -
Address
A
is a subaccount of the principal derived from the public key that you use to sign the transaction. -
The amount specified in the
FEE
operation is equal in absolute value tosuggested_fee
.
Optional metadata fields
Rosetta node recognizes the following optional metadata fields in ConstructionPayloadRequest:
-
memo
is an arbitrary 64-bit unsigned integer associated with the transaction. You can use it to associate your data with the transaction. For example, you can set the memo to a row key in a database. Valid values for thememo
field range from0
to264 - 1
(18446744073709551615
). -
ingress_start
,ingress_end
, andcreated_at_time
are 64-bit unsigned integers representing the number of nanoseconds passed from UNIX epoch in UTC timezone. You can use these fields to construct and sign a transaction in advance and submit the signed transaction later. You can submit a signed transaction within 24 hours starting fromcreated_at_time
(by default equal to the time when you invoke the/construction/payloads
endpoint).
Example
Below is an example of a transaction that transfers 1 ICP from address bdc4ee05d42cd0669786899f256c8fd7217fa71177bd1fa7b9534f568680a938
to address b64ec6f964d8597afa06d4209dbce2b2df9fe722e86aeda2351bd95500cf15f8
.
{
"network_identifier": {
"blockchain": "Internet Computer",
"network": "00000000000000020101"
},
"operations": [
{
"operation_identifier": {
"index": 0
},
"type": "TRANSACTION",
"account": {
"address": "bdc4ee05d42cd0669786899f256c8fd7217fa71177bd1fa7b9534f568680a938"
},
"amount": {
"value": "-100000000",
"currency": {
"symbol": "ICP",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 1
},
"type": "TRANSACTION",
"account": {
"address": "b64ec6f964d8597afa06d4209dbce2b2df9fe722e86aeda2351bd95500cf15f8"
},
"amount": {
"value": "100000000",
"currency": {
"symbol": "ICP",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 2
},
"type": "FEE",
"account": {
"address": "bdc4ee05d42cd0669786899f256c8fd7217fa71177bd1fa7b9534f568680a938"
},
"amount": {
"value": "-10000",
"currency": {
"symbol": "ICP",
"decimals": 8
}
}
}
],
"public_keys": [
{
"hex_bytes": "97d0b490ec4097b3653878274b1d9dd00bb1316ea3df0bfdf98327ef68fade63",
"curve_type": "edwards25519"
}
]
}