API Reference

Undelegate

Unstaking NEAR is a simple process. We will collect:

  • The delegating address
  • The signing address
  • The validator address to undelegate from
  • Amount of NEAR to be undelegated
  • Optionally, a maximum Boolean if you wish to undelegate the full amount without having to check the current balance
  • Optionally, a max gas amount (upper limit of the transaction fee to be paid)

Once the undelegation transaction is confirmed on-chain, the unbonding process will begin immediately.

NEAR has an unbonding period of four epochs (≈ 48-60h). During this time, the unbonding NEAR will be illiquid and will not earn rewards. Upon completion of the unbonding period, the NEAR will be available to be withdrawn.

📘

NOTE

If you have a balance waiting to be withdrawn and do not wish to undelegate more NEAR, you can use the create_withdraw_tx action to withdraw from that balance without first unbonding any NEAR.

In the following guide we will illustrate how to unstake NEAR.

Create New Unstaking Flow

To initiate the undelegation 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. unstaking).
{
  "protocol": "near",
  "network": "testnet",
  "operation": "unstaking"
}

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_undelegate_tx : Use this action to generate an undelegation transaction to unstake NEAR.
      • delegator_address : The delegator address.
      • delegator_pubkey : The public key of the signing account.
      • validator_address : Validator address from which NEAR will be undelegated.
      • undelegate_amount : The amount of NEAR to be undelegated.
      • undelegate_maximum : Set to trueif you wish to unbond the full delegated balance without needing to know the exact delegated balance.
      • max_gas : The maximum transaction fee.
  • data : object Flow & transaction data.
{
  "id": "4f866b7f-2e79-4c61-9bb4-398777c12a0b",
  "state": "initialized",
  "actions": [
    {
      "name": "create_withdraw_tx",
      "inputs": [
        {
          "name": "delegator_address",
          "display": "Delegator Address",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "delegator_pubkey",
          "display": "Delegator Pubkey",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "validator_address",
          "display": "Validator Address",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "withdraw_amount",
          "display": "Withdraw Amount",
          "description": "",
          "type": "decimal",
          "validations": [
            {
              "type": "presence",
              "options": {
                "unless": "withdraw_maximum"
              }
            },
            {
              "type": "numericality",
              "options": {
                "unless": "withdraw_maximum",
                "greater_than": 0
              }
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "withdraw_maximum",
          "display": "Withdraw Maximum",
          "description": "",
          "type": "boolean",
          "validations": [],
          "array": false,
          "default_value": null
        },
        {
          "name": "max_gas",
          "display": "Max Gas",
          "description": "in NEAR",
          "type": "decimal",
          "validations": [],
          "array": false,
          "default_value": null
        }
      ]
    },
    {
      "name": "create_undelegate_tx",
      "inputs": [
        {
          "name": "delegator_address",
          "display": "Delegator Address",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "delegator_pubkey",
          "display": "Delegator Pubkey",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "validator_address",
          "display": "Validator Address",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "undelegate_amount",
          "display": "Undelegate Amount",
          "description": "",
          "type": "decimal",
          "validations": [
            {
              "type": "presence",
              "options": {
                "unless": "undelegate_maximum"
              }
            },
            {
              "type": "numericality",
              "options": {
                "unless": "undelegate_maximum",
                "greater_than": 0
              }
            }
          ],
          "array": false,
          "default_value": null
        },
        {
          "name": "undelegate_maximum",
          "display": "Undelegate Maximum",
          "description": "",
          "type": "boolean",
          "validations": [],
          "array": false,
          "default_value": null
        },
        {
          "name": "max_gas",
          "display": "Max Gas",
          "description": "in NEAR",
          "type": "decimal",
          "validations": [],
          "array": false,
          "default_value": null
        }
      ]
    }
  ],
  "data": {
    "delegator_address": null,
    "delegator_pubkey": null,
    "validator_address": null,
    "max_gas": null,
    "undelegate_amount": null,
    "undelegate_maximum": null,
    "undelegate_transaction": null,
    "estimated_inactive_at": null,
    "withdraw_amount": null,
    "withdraw_maximum": null,
    "withdraw_transaction": null
  },
  "protocol": "near",
  "network": "testnet",
  "created_at": "2023-02-27T17:51:08.550Z",
  "updated_at": "2023-02-27T17:51:08.550Z"
}

Submit Undelegate Data

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

URL

https://api.figment.io/flows/[:flow_id]/next

Request

  • name* : create_undelegate_tx
  • inputs* : object
    • delegator_address* : string The delegator address.
    • delegator_pubkey* : string The pubkey of the signing account.
    • validator_address* : string Validator address from which NEAR will be undelegated.
    • undelegate_amount* : number The amount of NEAR to be undelegated.
    • undelegate_maximum : boolean Set to true if you wish to unbond the full delegated balance without needing to know the exact delegated balance.
    • max_gas : The maximum transaction fee.
{
  "name": "create_undelegate_tx",
  "inputs": {
    "validator_address": "01node.pool.f863973.m0",
    "delegator_address": "slate-demo.testnet",
    "delegator_pubkey": "ed25519:5QA46X6NkNmsFdu9xWVBaLNowh9gGeF1c5r9u6NcxaLY",
    "undelegate_amount": "25"
  }
}

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": "4f866b7f-2e79-4c61-9bb4-398777c12a0b",
  "state": "undelegate_tx_signature",
  "actions": [
    {
      "name": "refresh_undelegate_tx",
      "inputs": [
        {
          "name": "delegator_address",
          "display": "Delegator Address",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet"
        },
        {
          "name": "delegator_pubkey",
          "display": "Delegator Pubkey",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV"
        },
        {
          "name": "validator_address",
          "display": "Validator Address",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "legends.pool.f863973.m0"
        },
        {
          "name": "undelegate_amount",
          "display": "Undelegate Amount",
          "description": "",
          "type": "decimal",
          "validations": [
            {
              "type": "presence",
              "options": {
                "unless": "undelegate_maximum"
              }
            },
            {
              "type": "numericality",
              "options": {
                "unless": "undelegate_maximum",
                "greater_than": 0
              }
            }
          ],
          "array": false,
          "default_value": "5.0"
        },
        {
          "name": "undelegate_maximum",
          "display": "Undelegate Maximum",
          "description": "",
          "type": "boolean",
          "validations": [],
          "array": false,
          "default_value": null
        },
        {
          "name": "max_gas",
          "display": "Max Gas",
          "description": "in NEAR",
          "type": "decimal",
          "validations": [],
          "array": false,
          "default_value": null
        }
      ]
    },
    {
      "name": "sign_undelegate_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": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000"
        },
        {
          "name": "signatures",
          "display": "Signatures",
          "description": "",
          "type": "array_of_signatures",
          "validations": [],
          "array": true,
          "default_value": null,
          "element_type": "signature_data",
          "signers": [
            "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV"
          ],
          "transaction_payload": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
          "signing_payload": "ab06236a0916604347fbbfc0c803d374fd28e6eb69f2edce3c2e6ac23e1f0452",
          "inputs": {
            "input_klass": "Workflows::Signature",
            "input_instance": {
              "account_address": null,
              "signature": null
            },
            "flow": {
              "workflow_state": "undelegate_tx_signature",
              "id": 3808,
              "customer_id": 40,
              "chain_id": 7,
              "data": {
                "delegator_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
                "delegator_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
                "validator_address": "legends.pool.f863973.m0",
                "max_gas": null,
                "undelegate_amount": "5.0",
                "undelegate_maximum": null,
                "undelegate_transaction": {
                  "raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
                  "signing_payload": "ab06236a0916604347fbbfc0c803d374fd28e6eb69f2edce3c2e6ac23e1f0452",
                  "signed": null,
                  "hash": "CWc9R6SdHVwVHj1rhYiwBgK2sqkVdbBj1wG4QniUXwqT",
                  "status": null,
                  "error": null,
                  "signatures": null
                },
                "estimated_inactive_at": null,
                "withdraw_amount": null,
                "withdraw_maximum": null,
                "withdraw_transaction": null
              },
              "created_at": "2023-02-27T17:51:08.550Z",
              "updated_at": "2023-02-27T18:01:39.469Z",
              "id_public": "4f866b7f-2e79-4c61-9bb4-398777c12a0b",
              "supported_operation_id": 31
            },
            "flow_attributes": {},
            "empty_input": {
              "account_address": null,
              "signature": null
            }
          }
        }
      ]
    },
    {
      "name": "confirm_undelegate_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": {
    "delegator_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
    "delegator_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
    "validator_address": "legends.pool.f863973.m0",
    "max_gas": null,
    "undelegate_amount": "5.0",
    "undelegate_maximum": null,
    "undelegate_transaction": {
      "raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
      "signing_payload": "ab06236a0916604347fbbfc0c803d374fd28e6eb69f2edce3c2e6ac23e1f0452",
      "signed": null,
      "hash": "CWc9R6SdHVwVHj1rhYiwBgK2sqkVdbBj1wG4QniUXwqT",
      "status": null,
      "error": null,
      "signatures": null
    },
    "estimated_inactive_at": null,
    "withdraw_amount": null,
    "withdraw_maximum": null,
    "withdraw_transaction": null
  },
  "protocol": "near",
  "network": "testnet",
  "created_at": "2023-02-27T17:51:08.550Z",
  "updated_at": "2023-02-27T18:01:39.469Z"
}

Submit Signed Undelegate 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_undelegate_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_undelegate_tx",
  "inputs": {
    "transaction_payload": "12000000736c6174652d64656d6f2e746573746e657400415d57cdf21d28e35e0cfa864e895c18b4bc6a711642d38eb6762af81ec1cf3905cc1038fc5700001600000030316e6f64652e706f6f6c2e663836333937332e6d308e0f6b6bb5b283186516419e2d4c06a47f7d55b456b83947fb5f8fb815957df6010000000207000000756e7374616b65270000007b22616d6f756e74223a223235303030303030303030303030303030303030303030303030227d00e057eb481b00000000000000000000000000000000000000d27fe1cabf4535e130002217b79d743941e22110d0b3b3f446aba92d3416eb5774efb6aa925af5ebc78e459218de9ae0baeee7de0e4fad77d299ace7fcf80107"
  }
}

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.
    • undelegate_tx_broadcasting : Transaction has been broadcast and is waiting confirmation.
    • cool_down : Transaction has been confirmed and the delegation is unbonding.
  • actions : array It includes the name & inputs of all next possible actions.
  • data : object Flow & transaction data.
{
  "id": "4f866b7f-2e79-4c61-9bb4-398777c12a0b",
  "state": "undelegate_tx_broadcasting",
  "actions": [
    {
      "name": "wait",
      "estimated_state_change_at": "2023-02-27T18:30:37.767Z",
      "inputs": []
    }
  ],
  "data": {
    "delegator_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
    "delegator_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
    "validator_address": "legends.pool.f863973.m0",
    "max_gas": null,
    "undelegate_amount": "5.0",
    "undelegate_maximum": null,
    "undelegate_transaction": {
      "raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
      "signing_payload": "ab06236a0916604347fbbfc0c803d374fd28e6eb69f2edce3c2e6ac23e1f0452",
      "signed": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000006be83dd7cd920e48058cad0e8962b5abff1641ec07f0b5dd9e6f218e6f0d783b2f799113d87da39febaabda95e0bfdce07fabfc6583af55525b6a9ef6f9dfb01 ",
      "hash": "CWc9R6SdHVwVHj1rhYiwBgK2sqkVdbBj1wG4QniUXwqT",
      "status": null,
      "error": null,
      "signatures": []
    },
    "estimated_inactive_at": null,
    "withdraw_amount": null,
    "withdraw_maximum": null,
    "withdraw_transaction": null
  },
  "protocol": "near",
  "network": "testnet",
  "created_at": "2023-02-27T17:51:08.550Z",
  "updated_at": "2023-02-27T18:29:37.321Z"
}

Submit Withdraw 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* : create_withdraw_tx
  • inputs* : object
    • delegator_address* : string The delegator address.
    • delegator_pubkey* : string The pubkey of the signing account.
    • validator_address* : string Validator address from which NEAR will be undelegated.
    • withdraw_amount* : number The amount of NEAR to be withdrawn.
    • withdraw_maximum : boolean Set to true if you wish to withdraw the full available balance without needing to know the exact available balance.
    • max_gas : The maximum transaction fee.
{
  "name": "create_withdraw_tx",
  "inputs": {
    "validator_address": "01node.pool.f863973.m0",
    "delegator_address": "slate-demo.testnet",
    "delegator_pubkey": "ed25519:5QA46X6NkNmsFdu9xWVBaLNowh9gGeF1c5r9u6NcxaLY",
    "withdraw_amount": "25"
  }
}

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": "4f866b7f-2e79-4c61-9bb4-398777c12a0b",
  "operation": "unstaking",
  "state": "withdraw_tx_signature",
  "actions": [
    {
      "name": "refresh_withdraw_tx",
      "inputs": [
        {
          "name": "delegator_address",
          "display": "Delegator Address",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet"
        },
        {
          "name": "delegator_pubkey",
          "display": "Delegator Pubkey",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV"
        },
        {
          "name": "validator_address",
          "display": "Validator Address",
          "description": "",
          "type": "string",
          "validations": [
            {
              "type": "presence",
              "options": {}
            }
          ],
          "array": false,
          "default_value": "legends.pool.f863973.m0"
        },
        {
          "name": "withdraw_amount",
          "display": "Withdraw Amount",
          "description": "",
          "type": "decimal",
          "validations": [
            {
              "type": "presence",
              "options": {
                "unless": "withdraw_maximum"
              }
            },
            {
              "type": "numericality",
              "options": {
                "unless": "withdraw_maximum",
                "greater_than": 0
              }
            }
          ],
          "array": false,
          "default_value": "5.0"
        },
        {
          "name": "withdraw_maximum",
          "display": "Withdraw Maximum",
          "description": "",
          "type": "boolean",
          "validations": [],
          "array": false,
          "default_value": null
        },
        {
          "name": "max_gas",
          "display": "Max Gas",
          "description": "in NEAR",
          "type": "decimal",
          "validations": [],
          "array": false,
          "default_value": null
        }
      ]
    },
    {
      "name": "sign_withdraw_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": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa442e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30d7d1c76dbf0debe82e9e8c6a11ecb54be99e1d288ca1993e5071a2c68cdfaeed0100000002080000007769746864726177260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000"
        },
        {
          "name": "signatures",
          "display": "Signatures",
          "description": "",
          "type": "array_of_signatures",
          "validations": [],
          "array": true,
          "default_value": null,
          "element_type": "signature_data",
          "signers": [
            "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV"
          ],
          "transaction_payload": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa442e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30d7d1c76dbf0debe82e9e8c6a11ecb54be99e1d288ca1993e5071a2c68cdfaeed0100000002080000007769746864726177260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
          "signing_payload": "3d86e4c351bc002fd7fbdb0686cc872393c87ffe3a4470cb010857bc739d6784",
          "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_withdraw_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": {
    "delegator_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
    "delegator_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
    "validator_address": "legends.pool.f863973.m0",
    "max_gas": null,
    "undelegate_amount": "5.0",
    "undelegate_maximum": null,
    "undelegate_transaction": {
      "raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
      "signing_payload": "ab06236a0916604347fbbfc0c803d374fd28e6eb69f2edce3c2e6ac23e1f0452",
      "signed": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000006be83dd7cd920e48058cad0e8962b5abff1641ec07f0b5dd9e6f218e6f0d783b2f799113d87da39febaabda95e0bfdce07fabfc6583af55525b6a9ef6f9dfb01 ",
      "hash": "CWc9R6SdHVwVHj1rhYiwBgK2sqkVdbBj1wG4QniUXwqT",
      "status": "confirmed",
      "error": null,
      "signatures": [],
      "block_time": null
    },
    "estimated_inactive_at": "2023-03-01T18:29:48.741Z",
    "withdraw_amount": "5.0",
    "withdraw_maximum": null,
    "withdraw_transaction": {
      "raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa442e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30d7d1c76dbf0debe82e9e8c6a11ecb54be99e1d288ca1993e5071a2c68cdfaeed0100000002080000007769746864726177260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
      "signing_payload": "3d86e4c351bc002fd7fbdb0686cc872393c87ffe3a4470cb010857bc739d6784",
      "signed": null,
      "hash": "59BAsPfQtJEzaNJghq6HYDhTBupTUvm63FRNdXG447vb",
      "status": null,
      "error": null,
      "signatures": null,
      "block_time": null
    }
  },
  "protocol": "near",
  "network": "testnet",
  "created_at": "2023-02-27T17:51:08.550Z",
  "updated_at": "2023-03-01T18:14:38.809Z"
}

Submit Signed Withdraw 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 NEAR network.

URL

https://api.figment.io/flows/[:flow_id]/next

Request

  • name* : sign_withdraw_tx
  • inputs* : object
    • transaction_payload* : string 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_withdraw_tx",
  "inputs": {
    "transaction_payload": "12000000736c6174652d64656d6f2e746573746e657400415d57cdf21d28e35e0cfa864e895c18b4bc6a711642d38eb6762af81ec1cf3907cc1038fc5700001600000030316e6f64652e706f6f6c2e663836333937332e6d3084edd29289b3a590be582317bb0061016a8df058b7c29a0278f5b82f86c283010100000002080000007769746864726177270000007b22616d6f756e74223a223235303030303030303030303030303030303030303030303030227d00e057eb481b00000000000000000000000000000000000000235397dfd3f0b7ce06a4fe11395e36ce40d12610eae07dcc1dc1d962b38fa9592cdc22f6c9164b0155967a773c369719f71d76b84185ec13c39381343c63cf0b"
  }
}

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.
    • withdraw_tx_broadcasting : Transaction has been broadcast and is waiting for confirmation.
    • withdrawn : Transaction has been confirmed and the withdrawal is complete.
  • actions : array It includes the name & inputs of all next possible actions.
  • data : object Flow & transaction data.
{
  "id": "4f866b7f-2e79-4c61-9bb4-398777c12a0b",
  "operation": "unstaking",
  "state": "withdraw_tx_broadcasting",
  "actions": [
    {
      "name": "wait",
      "estimated_state_change_at": "2023-03-01T18:23:50.088Z",
      "inputs": []
    }
  ],
  "data": {
    "delegator_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
    "delegator_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
    "validator_address": "legends.pool.f863973.m0",
    "max_gas": null,
    "undelegate_amount": "5.0",
    "undelegate_maximum": null,
    "undelegate_transaction": {
      "raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
      "signing_payload": "ab06236a0916604347fbbfc0c803d374fd28e6eb69f2edce3c2e6ac23e1f0452",
      "signed": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa422e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30f95da7beed58598a6e813c1303a2374028fe6cfe76f467ee656899c7400c640d010000000207000000756e7374616b65260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000006be83dd7cd920e48058cad0e8962b5abff1641ec07f0b5dd9e6f218e6f0d783b2f799113d87da39febaabda95e0bfdce07fabfc6583af55525b6a9ef6f9dfb01 ",
      "hash": "CWc9R6SdHVwVHj1rhYiwBgK2sqkVdbBj1wG4QniUXwqT",
      "status": "confirmed",
      "error": null,
      "signatures": [],
      "block_time": null
    },
    "estimated_inactive_at": "2023-03-01T18:29:48.741Z",
    "withdraw_amount": "5.0",
    "withdraw_maximum": null,
    "withdraw_transaction": {
      "raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa442e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30d7d1c76dbf0debe82e9e8c6a11ecb54be99e1d288ca1993e5071a2c68cdfaeed0100000002080000007769746864726177260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000",
      "signing_payload": "3d86e4c351bc002fd7fbdb0686cc872393c87ffe3a4470cb010857bc739d6784",
      "signed": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa442e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d30d7d1c76dbf0debe82e9e8c6a11ecb54be99e1d288ca1993e5071a2c68cdfaeed0100000002080000007769746864726177260000007b22616d6f756e74223a2235303030303030303030303030303030303030303030303030227d00e057eb481b000000000000000000000000000000000000002a6cea608a947eabef4ae001074c91d02ce9ba57247d741d927fa342513b585f243b3cb6a326922cadbd528a6b5e1b2b4ad5f7e1791dc3e5623f01d1e0917c0c",
      "hash": "59BAsPfQtJEzaNJghq6HYDhTBupTUvm63FRNdXG447vb",
      "status": null,
      "error": null,
      "signatures": [],
      "block_time": null
    }
  },
  "protocol": "near",
  "network": "testnet",
  "created_at": "2023-02-27T17:51:08.550Z",
  "updated_at": "2023-03-01T18:22:49.608Z"
}

Get Unstaking 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.
    • undelegate_tx_broadcasting : Transaction has been broadcast and is confirming.
    • cool_down : Transaction has been confirmed and the unbonding period is active.
    • withdraw_tx_broadcasting : Transaction has been broadcast and is confirming.
    • withdrawn : Undelegated NEAR has been withdrawn.
  • actions : array It includes the name & inputs of all next possible actions.
  • data : object Flow & transaction data.
{
  "id": "549db585-874f-4b5d-b1a2-67b7d9a3df15",
  "state": "cool_down",
  "actions": [
    {
      "name": "wait",
      "estimated_state_change_at": "2022-09-28T16:24:34.472Z",
      "inputs": []
    }
  ],
  "data": {
    "delegator_address": "0b81cc09294fc074814ad0de50f31644e5669f856105399b.testnet",
    "delegator_pubkey": "ed25519:NUbTcj78nHFFm1J8a1GFjenAnCKV32ZdBeeqem8oyLV",
    "validator_address": "legends.pool.f863973.m0",
    "undelegate_amount": "10.0",
    "undelegate_transaction": {
      "raw": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa412e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d3060877de2656b98d64e2cecadb55050ee8aa435e81dc657911adc65bb569bf7fb0100000002110000006465706f7369745f616e645f7374616b65020000007b7d00e057eb481b00000000004a480114169545080000000000",
      "signing_payload": "c9f587150ebf9aa0d8c20510a71574a094224c636a1d40e9c80e13f7d0ed04ea",
      "signed": "380000003062383163633039323934666330373438313461643064653530663331363434653536363966383536313035333939622e746573746e657400058065d39e25bf5038afbacc1b7312c5dc3761770626288020d783f8685058aa412e4c11c36b0000170000006c6567656e64732e706f6f6c2e663836333937332e6d3060877de2656b98d64e2cecadb55050ee8aa435e81dc657911adc65bb569bf7fb0100000002110000006465706f7369745f616e645f7374616b65020000007b7d00e057eb481b00000000004a480114169545080000000000007a3f50c131f084dc733fc56e16c888fc7f42a0e49000e8948065e1663d1f57849788b40dfbabdc1e6734d78f6fe4e7803372a251fb9c9473ca443575102b1303",
      "hash": "EbN6QPxd81V8CGViBFMtTjoqnoPV5bH34kyiV5vu9XvH",
      "status": "confirmed",
      "error": null,
      "signatures": []
    },
    "estimated_inactive_at": "2022-09-28T16:24:34.472Z",
    "withdraw_amount": "",
    "withdraw_maximum": null,
    "withdraw_transaction": null
  },
  "protocol": "near",
  "network": "testnet",
  "created_at": "2023-02-27T17:46:45.944Z",
  "updated_at": "2023-02-27T17:48:05.958Z"
}