API Reference

Transfer

To transfer tokens from one address to another on Solana, you will need:

  • The sending address
  • The receiving address
  • The amount of Solana

The Staking API manages the rest.

In the following guide we will illustrate how to transfer SOL.

Create New Transfer Flow

To initiate the transfer process with Staking API, create a new flow with POST /flows.

URL

https://api.figment.io/flows

Request

  • protocol* : string Protocol on which this flow operates (ex. solana).
  • network* : string Network on which this flow operates (ex. mainnet , testnet).
  • operation* : string The operation to perform (ex. transfer).
{
  "protocol": "solana",
  "network": "devnet",
  "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 the name & inputs of all next possible actions.
    • create_transfer_tx : Use this action to generate a transfer transaction to move SOL between accounts.
      • funding_account_pubkey : The public key of the wallet which will pay the transaction fee.
      • from_account_pubkey : The wallet that SOL will be originating from.
      • to_account_pubkey : The withdrawal address for the given validator.
      • amount : The amount of SOL to be transferred to the account. This field should be in full SOL, not in lamports (ie. if you want to transfer 5 SOL, return "amount": 5.0). The Staking API will translate the amount to lamports so you do not have to worry about the conversion factor. Lamports are fractional SOLs.
  • data : object Flow & transaction data.
{
  "id": "6b8502c2-77b3-4541-a742-62ff337f0d15",
  "operation": "transfer",
  "state": "initialized",
  "actions": [
    {
      "name": "create_transfer_tx",
      "inputs": [
        {
          "name": "funding_account_pubkey",
          "display": "Funding Account Pubkey",
          "description": "",
          "type": "string",
          "validations": [],
          "array": false,
          "default_value": null
        },
        {
          "name": "from_account_pubkey",
          "display": "From Account Pubkey",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "to_account_pubkey",
          "display": "To Account Pubkey",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "amount",
          "display": "Amount",
          "description": "in SOL",
          "type": "decimal",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        }
      ]
    }
  ],
  "data": {
    "from_account_pubkey": null,
    "to_account_pubkey": null,
    "amount": null,
    "funding_account_pubkey": null,
    "transfer_transaction": null
  },
  "protocol": "solana",
  "ntework": "devnet",
  "created_at": "2023-02-28T09:32:03.904Z",
  "updated_at": "2023-02-28T09:32:03.904Z"
}

Submit Transfer Data

After creating the new transfer flow, we need to submit the transfer data.

After collecting the required inputs as mentioned below, send a PUT request to /flows/[:flow_id]/next to proceed to the next step.

Request

  • name* : create_transfer_tx
  • inputs* : object
    • from_account_pubkey* : string The address of the sender's account.
    • to_account_pubkey* : string The address of the wallet to which SOL will be transferred.
    • amount* : number — The amount of the tokens you want to transfer.
    • funding_account_pubkey : string Pubkey of the wallet which will pay the transaction fee.
{
  "name": "create_transfer_tx",
  "inputs": {
    "from_account_address": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
    "from_account_pubkey": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
    "to_account_pubkey": "9c8oxENj8XrEM2EMadxUoifZgB1Vbc8GEYqKTxTfPo3i",
    "amount": 1
  }
}

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 the name & inputs of all next possible actions.

  • data : object Flow & transaction data.

{
  "id": "6b8502c2-77b3-4541-a742-62ff337f0d15",
  "operation": "transfer",
  "state": "transfer_tx_signature",
  "actions": [
    {
      "name": "refresh_transfer_tx",
      "inputs": [
        {
          "name": "funding_account_pubkey",
          "display": "Funding Account Pubkey",
          "description": "",
          "type": "string",
          "validations": [],
          "array": false,
          "default_value": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy"
        },
        {
          "name": "from_account_pubkey",
          "display": "From Account Pubkey",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy"
        },
        {
          "name": "to_account_pubkey",
          "display": "To Account Pubkey",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "9c8oxENj8XrEM2EMadxUoifZgB1Vbc8GEYqKTxTfPo3i"
        },
        {
          "name": "amount",
          "display": "Amount",
          "description": "in SOL",
          "type": "decimal",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "1.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": [
            "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy"
          ],
          "transaction_payload": "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000"
        },
        {
          "name": "signatures",
          "display": "Signatures",
          "description": "",
          "type": "array_of_signatures",
          "validations": [],
          "array": true,
          "default_value": null,
          "element_type": "signature_data",
          "signers": [
            "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy"
          ],
          "transaction_payload": "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
          "signing_payload": "01000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
          "inputs": [
            {
              "name": "account_address",
              "display": "Account Address",
              "description": "",
              "type": "string",
              "validations": [
                {
                  "type": "presence",
                  "options": {}
                }
              ],
              "array": false,
              "default_value": null
            },
            {
              "name": "signature",
              "display": "Signature",
              "description": "",
              "type": "string",
              "validations": [
                {
                  "type": "presence",
                  "options": {}
                }
              ],
              "array": false,
              "default_value": 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": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
    "to_account_pubkey": "9c8oxENj8XrEM2EMadxUoifZgB1Vbc8GEYqKTxTfPo3i",
    "amount": "1.0",
    "funding_account_pubkey": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
    "transfer_transaction": {
      "raw": "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
      "signing_payload": "01000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
      "signed": null,
      "hash": null,
      "status": null,
      "error": null,
      "signatures": null,
      "block_time": null
    }
  },
  "protocol": "solana",
  "network": "devnet",
  "created_at": "2023-02-28T09:32:03.904Z",
  "updated_at": "2023-02-28T09:37:45.799Z"
}

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 and the Staking API will broadcast the transaction to the network.

🚧

The transaction signing window on Solana is sometimes less than 90 seconds.

If you encounter an error "Transaction simulation failed: Blockhash not found", refresh the transaction, sign the newly created payload and submit it in < 90 seconds.

Request

  • name* : sign_transfer_tx
  • inputs* : object
    • transaction_payload* : Signed transaction payload from the previous step's response.
    • signatures : array of object 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": "01c9e6e53b2165b582192710482f23178d5c7a6d5666cc97f841e07cd983265033f73790fd6650b298ee908e5a42927a68212f6368029a4b9e4e5961e0ca24a70801000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000"
  }
}

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 awaiting confirmation.
    • transferred : Transaction is confirmed and tokens are transferred.
  • actions : array It includes the name & inputs of all next possible actions.
  • data : object Flow & transaction data.
{
  "id": "6b8502c2-77b3-4541-a742-62ff337f0d15",
  "operation": "transfer",
  "state": "transfer_tx_broadcasting",
  "actions": [
    {
      "name": "wait",
      "estimated_state_change_at": "2023-02-28T09:39:53.205Z",
      "inputs": []
    }
  ],
  "data": {
    "from_account_pubkey": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
    "to_account_pubkey": "9c8oxENj8XrEM2EMadxUoifZgB1Vbc8GEYqKTxTfPo3i",
    "amount": "1.0",
    "funding_account_pubkey": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
    "transfer_transaction": {
      "raw": "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
      "signing_payload": "01000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
      "signed": "01c9e6e53b2165b582192710482f23178d5c7a6d5666cc97f841e07cd983265033f73790fd6650b298ee908e5a42927a68212f6368029a4b9e4e5961e0ca24a70801000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
      "hash": "538M3ptZsiHeDaRWX6RnFeuCbJcUwfDSU8YzDRBJnPx1AEQvk3to7n1VEWQyCz87oqZpsLC8obvxJNQizMCQauHZ",
      "status": null,
      "error": null,
      "signatures": [
        {
          "account_address": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
          "signature": ""
        }
      ],
      "block_time": null
    }
  },
  "protocol": "solana",
  "network": "devnet",
  "created_at": "2023-02-28T09:32:03.904Z",
  "updated_at": "2023-02-28T09:38:52.469Z"
}

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.

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 but not confirmed.
    • transferred : Transaction broadcasted and confirmed.
  • actions : array It includes the name & inputs of all next possible actions.
  • data : object Flow & transaction data.

Example response at end of flow

{
  "id": "6b8502c2-77b3-4541-a742-62ff337f0d15",
  "operation": "transfer",
  "state": "transfered",
  "actions": [],
  "data": {
    "from_account_pubkey": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
    "to_account_pubkey": "9c8oxENj8XrEM2EMadxUoifZgB1Vbc8GEYqKTxTfPo3i",
    "amount": "1.0",
    "funding_account_pubkey": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
    "transfer_transaction": {
      "raw": "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
      "signing_payload": "01000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
      "signed": "01c9e6e53b2165b582192710482f23178d5c7a6d5666cc97f841e07cd983265033f73790fd6650b298ee908e5a42927a68212f6368029a4b9e4e5961e0ca24a70801000103f8c4898641adada76eeeee2de872d931bc58bfb2ce5b79734e32808cc501a5347fdda76b682402ecb38e705b77d7eee793c587b6294a461c14ad89e7e161ade500000000000000000000000000000000000000000000000000000000000000008a20e5a91435e4f72d11db3e291b4797b6830cd2187f94596bca768ca81a5dff01020200010c0200000000ca9a3b00000000",
      "hash": "538M3ptZsiHeDaRWX6RnFeuCbJcUwfDSU8YzDRBJnPx1AEQvk3to7n1VEWQyCz87oqZpsLC8obvxJNQizMCQauHZ",
      "status": "confirmed",
      "error": null,
      "signatures": [
        {
          "account_address": "Hk5voGB7wh9HtXTeszbW7AFm3A4B94xWkXeeaqTYspqy",
          "signature": ""
        }
      ],
      "block_time": null
    }
  },
  "protocol": "solana",
  "network": "devnet",
  "created_at": "2023-02-28T09:32:03.904Z",
  "updated_at": "2023-02-28T09:38:52.469Z"
}