Transferring NEAR is a simple process. We will collect:
- The address from which NEAR is transferred
- The account that will sign the transaction
- The address to which NEAR is transferred
- Amount of NEAR to be transferred
Once the transfer transaction is confirmed on-chain, the transfer of NEAR between accounts is complete.
In the following guide we will illustrate how to transfer NEAR between accounts.
Create New Transfer Flow
To initiate the transfer process, create a new flow with a POST
request to /flows
.
URL
https://api.figment.io/flows
Request
protocol
* :string
Protocol this flow operates on (ex.near
).network
* :string
Network this flow operates on (ex.testnet
).operation
* :string
The operation to perform (ex.transfer
).
{
"protocol": "near",
"network": "testnet",
"operation": "transfer"
}
Response
id
:string
ID of the flow.operation
:string
The Staking API operation being performed by this flow.state
:string
The current state of the flow.actions
:array
It includes thename
&inputs
of all next possible actions.create_transfer_tx
: Use this action to transfer NEAR.from_account_address
: The address from which NEAR will be transferred.from_account_pubkey
: The account that will sign the transaction.to_account_address
: The address to which NEAR will be transferred.amount
: The amount of NEAR to be transferred.
data
:object
Flow & transaction data.
{
"id": "79d4a437-e964-4f90-ba19-998d0de8c1cb",
"state": "initialized",
"actions": [
{
"name": "create_transfer_tx",
"inputs": [
{
"name": "from_account_pubkey",
"display": "From Account Pubkey",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": null
},
{
"name": "from_account_address",
"display": "From Account Address",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": null
},
{
"name": "to_account_address",
"display": "To Account Address",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": null
},
{
"name": "amount",
"display": "Amount",
"description": "in NEAR",
"type": "decimal",
"validations": [
{
"type": "presence",
"options": {}
},
{
"type": "numericality",
"options": {
"greater_than": 0
}
}
],
"array": false,
"default_value": null
}
]
}
],
"data": {
"from_account_pubkey": null,
"from_account_address": null,
"to_account_address": null,
"amount": null,
"transfer_transaction": null
},
"protocol": "near",
"network": "testnet",
"created_at": "2023-02-27T18:35:44.613Z",
"updated_at": "2023-02-27T18:35:44.613Z"
}
Submit Transfer Data
After collecting the required inputs, send a PUT
request to /flows/[:flow_id]/next
to move on to the next step.
URL
https://api.figment.io/flows/[:flow_id]/next
Request
name
* :string
:create_transfer_tx
.inputs
* :object
from_account_pubkey
* :string
The account that will sign the transaction.from_account_address
* :string
the address from which NEAR will be transferred.to_account_address
* :string
The address to which NEAR will be transferred.amount
* :number
The amount of NEAR to be transferred.
{
"name": "create_transfer_tx",
"inputs": {
"from_account_address": "slate-demo.testnet",
"from_account_pubkey": "ed25519:5QA46X6NkNmsFdu9xWVBaLNowh9gGeF1c5r9u6NcxaLY",
"to_account_address": "pizza.testnet",
"amount": "10"
}
}
Response
id
:string
ID of the flow.operation
:string
The Staking API operation being performed by this flow.state
:string
The current state of the flow.actions
:array
It includes thename
&inputs
of all next possible actions.refresh_transfer_tx
: If you need to get a fresh version of the transaction payload (i.e., the nonce has increased).sign_transfer_tx
: Submit a signed transaction payload or an array of signatures to continue the flow. Refer to the guides Signing Transactions with Figment's npm Package and Signing Transactions with the Fireblocks API for details.confirm_transfer_tx_by_hash
: Submit a previously completed transaction hash to continue the flow. Refer to the guide Advance Flows Using a Transaction Hash.
data
:object
Flow & transaction data.
{
"id": "79d4a437-e964-4f90-ba19-998d0de8c1cb",
"state": "transfer_tx_signature",
"actions": [
{
"name": "refresh_transfer_tx",
"inputs": [
{
"name": "from_account_pubkey",
"display": "From Account Pubkey",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV"
},
{
"name": "from_account_address",
"display": "From Account Address",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet"
},
{
"name": "to_account_address",
"display": "To Account Address",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": "slate-demo.testnet"
},
{
"name": "amount",
"display": "Amount",
"description": "in NEAR",
"type": "decimal",
"validations": [
{
"type": "presence",
"options": {}
},
{
"type": "numericality",
"options": {
"greater_than": 0
}
}
],
"array": false,
"default_value": "50.0"
}
]
},
{
"name": "sign_transfer_tx",
"inputs": [
{
"name": "transaction_payload",
"display": "Transaction Payload",
"description": "",
"type": "signed_transaction",
"validations": [
{
"type": "sign_payload",
"options": {}
}
],
"array": false,
"default_value": null,
"signers": [
"ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV"
],
"transaction_payload": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa432e4c11c36b000012000000736c6174652d64656d6f2e746573746e657415143914926d227d21ea635e6ae70a967ad19ad74dd305ac3a556968fd9039170100000003000000726906646ee95b290000000000"
},
{
"name": "signatures",
"display": "Signatures",
"description": "",
"type": "array_of_signatures",
"validations": [],
"array": true,
"default_value": null,
"element_type": "signature_data",
"signers": [
"ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV"
],
"transaction_payload": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa432e4c11c36b000012000000736c6174652d64656d6f2e746573746e657415143914926d227d21ea635e6ae70a967ad19ad74dd305ac3a556968fd9039170100000003000000726906646ee95b290000000000",
"signing_payload": "87050c63e63a1269228176a458743c99d23ca12ad9c9758a42c10e56799dc8c3",
"inputs": {
"input_klass": "Workflows::Signature",
"input_instance": {
"account_address": null,
"signature": null
},
"flow": {
"workflow_state": "transfer_tx_signature",
"id": 3810,
"customer_id": 40,
"chain_id": 7,
"data": {
"from_account_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
"from_account_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
"to_account_address": "slate-demo.testnet",
"amount": "50.0",
"transfer_transaction": {
"raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa432e4c11c36b000012000000736c6174652d64656d6f2e746573746e657415143914926d227d21ea635e6ae70a967ad19ad74dd305ac3a556968fd9039170100000003000000726906646ee95b290000000000",
"signing_payload": "87050c63e63a1269228176a458743c99d23ca12ad9c9758a42c10e56799dc8c3",
"signed": null,
"hash": "A64WEYru3xv7jQsCDn9JV4RYK4frvNWtfAUUMYQmcVLn",
"status": null,
"error": null,
"signatures": null
}
},
"created_at": "2023-02-27T18:35:44.613Z",
"updated_at": "2023-02-27T18:40:29.791Z",
"id_public": "79d4a437-e964-4f90-ba19-998d0de8c1cb",
"supported_operation_id": 19
},
"flow_attributes": {},
"empty_input": {
"account_address": null,
"signature": null
}
}
}
]
},
{
"name": "confirm_transfer_tx_by_hash",
"inputs": [
{
"name": "hash",
"display": "Hash",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": null
},
{
"name": "block_number",
"display": "Block Number",
"description": "",
"type": "integer",
"validations": [],
"array": false,
"default_value": null
}
]
}
],
"data": {
"from_account_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
"from_account_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
"to_account_address": "slate-demo.testnet",
"amount": "50.0",
"transfer_transaction": {
"raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa432e4c11c36b000012000000736c6174652d64656d6f2e746573746e657415143914926d227d21ea635e6ae70a967ad19ad74dd305ac3a556968fd9039170100000003000000726906646ee95b290000000000",
"signing_payload": "87050c63e63a1269228176a458743c99d23ca12ad9c9758a42c10e56799dc8c3",
"signed": null,
"hash": "A64WEYru3xv7jQsCDn9JV4RYK4frvNWtfAUUMYQmcVLn",
"status": null,
"error": null,
"signatures": null
}
},
"protocol": "near",
"network": "testnet",
"created_at": "2023-02-27T18:35:44.613Z",
"updated_at": "2023-02-27T18:40:29.791Z"
}
Submit Signed Transfer Transaction for Broadcast
Before broadcasting the transaction, you must sign the transaction_payload
you received in the previous step. After signing the transaction, send a PUT
request to /flows/[:flow_id]/next
with the signed payload. The Staking API will broadcast the transaction to the NEAR network.
URL
https://api.figment.io/flows/[:flow_id]/next
Request
name
* :sign_transfer_tx
inputs
* :object
transaction_payload
* : Signed transaction payload from the previous step's response.signatures
:array
ofobject
The signatures array can be used instead of sending a transaction payload when the signing keys are kept in a custodial solution, such as Fireblocks. Refer to the guide Signing Transactions with the Fireblocks API for details.
{
"name": "sign_transfer_tx",
"inputs": {
"transaction_payload": "12000000736c6174652d64656d6f2e746573746e657400415d57cdf21d28e35e0cfa864e895c18b4bc6a711642d38eb6762af81ec1cf3906cc1038fc5700000d00000070697a7a612e746573746e657490121aa419ea5a902edec74ac78626fd251b8466f4c637f3ded5f0898014448001000000030000004a48011416954508000000000000e7a0bf4947796c6c2962084dccd3c97fa1b78de1fab4765ab3d2cadf3e6c90b6290d5aae0a79b7c0a5bc31120210591135a7604fcc12ecc4b3b34d7513e73a0b"
}
}
Response
id
:string
ID of the flow.operation
:string
The Staking API operation being performed by this flow.state
:string
The current state of the flow.transfer_tx_broadcasting
: Transaction has been broadcast and is waiting confirmation.transferred
: Transaction has been confirmed and the transfer is complete.
actions
:array
It includes thename
&inputs
of all next possible actions.data
:object
Flow & transaction data.
{
"id": "79d4a437-e964-4f90-ba19-998d0de8c1cb",
"state": "transfer_tx_broadcasting",
"actions": [
{
"name": "wait",
"estimated_state_change_at": "2023-02-27T18:45:13.315Z",
"inputs": []
}
],
"data": {
"from_account_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
"from_account_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
"to_account_address": "slate-demo.testnet",
"amount": "50.0",
"transfer_transaction": {
"raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa432e4c11c36b000012000000736c6174652d64656d6f2e746573746e657415143914926d227d21ea635e6ae70a967ad19ad74dd305ac3a556968fd9039170100000003000000726906646ee95b290000000000",
"signing_payload": "87050c63e63a1269228176a458743c99d23ca12ad9c9758a42c10e56799dc8c3",
"signed": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa432e4c11c36b000012000000736c6174652d64656d6f2e746573746e657415143914926d227d21ea635e6ae70a967ad19ad74dd305ac3a556968fd9039170100000003000000726906646ee95b2900000000000069cab19548fcac9253ef66fde2853aa46611ac42aeae30d4109fae9a026de1ba67a4c55fe576a019898e8a1b817c93d02779dfd1be63fde390e0bf576cb67404",
"hash": "A64WEYru3xv7jQsCDn9JV4RYK4frvNWtfAUUMYQmcVLn",
"status": null,
"error": null,
"signatures": []
}
},
"protocol": "near",
"network": "testnet",
"created_at": "2023-02-27T18:35:44.613Z",
"updated_at": "2023-02-27T18:44:12.803Z"
}
Get Transfer Flow Status
To get the current state of the existing flow, send a GET
request to /flows/[:flow_id]
using the flow ID from the previous step.
URL
https://api.figment.io/flows/[:flow_id]
Request
- None
Response
id
:string
ID of the flow.operation
:string
The Staking API operation being performed by this flow.state
:string
The current state of the flow.transfer_tx_broadcasting
: Transaction has been broadcast and is confirming.delegated
: Transaction has been confirmed and the delegation is active.
actions
:array
It includes thename
&inputs
of all next possible actions.data
:object
Flow & transaction data.
{
"id": "549db585-874f-4b5d-b1a2-67b7d9a3df15",
"state": "transferred",
"actions": [],
"data": {
"from_account_pubkey": "ed25519:5QA46X6NkNmsFdu9xWVBaLNowh9gGeF1c5r9u6NcxaLY",
"from_account_address": "slate-demo.testnet",
"to_account_address": "pizza.testnet",
"amount": "10.0",
"transfer_transaction": {
"raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa412e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d3060877de2656b98d64e2cecadb55050ee8aa435e81dc657911adc65bb569bf7fb0100000002110000006465706f7369745f616e645f7374616b65020000007b7d00e057eb481b00000000004a480114169545080000000000",
"signing_payload": "c9f587150ebf9aa0d8c20510a71574a094224c636a1d40e9c80e13f7d0ed04ea",
"signed": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa412e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d3060877de2656b98d64e2cecadb55050ee8aa435e81dc657911adc65bb569bf7fb0100000002110000006465706f7369745f616e645f7374616b65020000007b7d00e057eb481b00000000004a480114169545080000000000007a3f50c131f084dc733fc56e16c888fc7f42a0e49000e8948065e1663d1f57849788b40dfbabdc1e6734d78f6fe4e7803372a251fb9c9473ca443575102b1303",
"hash": "EbN6QPxd81V8CGViBFMtTjoqnoPV5bH34kyiV5vu9XvH",
"status": "confirmed",
"error": null,
"signatures": []
}
},
"protocol": "near",
"network": "testnet",
"created_at": "2023-02-27T17:46:45.944Z",
"updated_at": "2023-02-27T17:48:05.958Z"
}