Delegate
Staking ATOM is a simple process. We will collect:
- The
delegator_addressfrom which ATOM is being delegated, which will sign the transaction. - The validator_address to which ATOM is delegated (Figment's is:
cosmosvaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpfdn6m9d) - The amount of ATOM to be delegated.
- An optional memo to identify the transaction.
- An optional
gas_limitandgas_pricein ATOM.
In the following guide we will illustrate how to stake ATOM.
Create New Staking Flow
To initiate the staking process, create a new flow with a POST request to /flows.
URL
https://api.figment.io/flows
Request
protocol* :stringProtocol this flow operates on (ex.cosmos).network* :stringNetwork this flow operates on (ex.testnet).operation* :stringThe operation to perform (ex.staking).
JSON
{
"protocol": "cosmos",
"network": "testnet",
"operation": "staking"
}
Response
id:stringID of the flow.operation:stringThe Staking API operation being performed by this flow.state:stringThe current state of the flow.actions:arrayIt includes thename&inputsof all next possible actions.create_delegate_tx: Use this action to generate a delegation transaction to stake your ATOM.delegator_address: The address from which ATOM will be delegated.validator_address: The validator address to which ATOM will be delegated.amount: The amount of ATOM to be delegated.memo: an optional message to record on-chain with your transaction.gas_limit: the total amount of gas you're willing to let this transaction consume.
If you do not include this, we'll use a Cosmos library to select a good default for you.
gas_price: how many ATOM you're willing to pay per unit of gas consumed by this transaction.
If you do not include this, we'll use a Cosmos library to select a good default for you.
pubkey: Pubkey value will be retrieved from the chain but if you're using a fresh account (that does not have any outgoing activity) then this information is not available and it requires the user to pass it.
data:objectFlow & transaction data.
JSON
{
"id": "1d823c7f-be8a-430e-85cf-7269206cd867",
"operation": "staking",
"state": "initialized",
"actions": [
{
"name": "create_delegate_tx",
"inputs": [
{
"name": "delegator_address",
"display": "Delegator Address",
"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": {}
},
{
"type": "format",
"options": {
"with": "(?-mix:\Acosmosvaloper.*)",
"message": "should start with `cosmosvaloper`"
}
}
],
"array": false,
"default_value": null
},
{
"name": "amount",
"display": "Amount",
"description": "",
"type": "decimal",
"validations": [],
"array": false,
"default_value": null
},
{
"name": "memo",
"display": "Memo",
"description": "",
"type": "string",
"validations": [],
"array": false,
"default_value": null
},
{
"name": "gas_price",
"display": "Gas Price",
"description": "",
"type": "decimal",
"validations": [],
"array": false,
"default_value": null
},
{
"name": "gas_limit",
"display": "Gas Limit",
"description": "",
"type": "decimal",
"validations": [],
"array": false,
"default_value": null
},
{
"name": "pubkey",
"display": "Pubkey",
"description": "Value will be retrieved from the chain if available",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": null
}
]
}
],
"data": {
"delegator_address": null,
"validator_address": null,
"amount": null,
"memo": null,
"gas_price": null,
"gas_limit": null,
"delegate_transaction": null,
"pubkey": null
},
"protocol": "cosmos",
"network": "testnet",
"created_at": "2023-02-28T10:45:13.156Z",
"updated_at": "2023-02-28T10:45:13.156Z"
}
Submit Delegate 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_delegate_txinputs* :objectdelegator_address* :stringThe address from which ATOM will be delegated.validator_address* :stringThe validator address to which ATOM will be delegated.amount* :numberThe amount of ATOM to be delegated.memo:stringA message to record on-chain with your transfer.gas_limit:numberThe total amount of gas you're willing to let this transaction consume.gas_price:numberHow many ATOM you're willing to pay per unit of gas consumed by this transaction.pubkey:stringRequired only if you're using a fresh account (that does not have any outgoing activity) else optional.
JSON
{
"name": "create_delegate_tx",
"inputs": {
"delegator_address": "cosmos1u85upk2v7pr65g0wv2976zleu6v8qjl9qprvzl",
"validator_address": "cosmosvaloper1tflk30mq5vgqjdly92kkhhq3raev2hnz6eete3",
"amount": 2
}
}
Response
id:stringID of the flow.operation:stringThe Staking API operation being performed by this flow.state:stringThe current state of the flow.actions:arrayIt includes thename&inputsof all next possible actions.refresh_delegate_tx: If you need to get a fresh version of the transaction payload (i.e., the nonce has increased).sign_delegate_tx: Submit a signed transaction payload or an array of signatures to continue the flow.confirm_delegate_tx_by_hash: Submit a previously completed transaction hash to continue the flow.
data:objectFlow & transaction data.
JSON
{
"id": "1d823c7f-be8a-430e-85cf-7269206cd867",
"operation": "staking",
"state": "delegate_tx_signature",
"actions": [
{
"name": "refresh_delegate_tx",
"inputs": [
{
"name": "delegator_address",
"display": "Delegator Address",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": "cosmos1u85upk2v7pr65g0wv2976zleu6v8qjl9qprvzl"
},
{
"name": "validator_address",
"display": "Validator Address",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
},
{
"type": "format",
"options": {
"with": "(?-mix:\Acosmosvaloper.*)",
"message": "should start with `cosmosvaloper`"
}
}
],
"array": false,
"default_value": "cosmosvaloper1tflk30mq5vgqjdly92kkhhq3raev2hnz6eete3"
},
{
"name": "amount",
"display": "Amount",
"description": "",
"type": "decimal",
"validations": [],
"array": false,
"default_value": "2.0"
},
{
"name": "memo",
"display": "Memo",
"description": "",
"type": "string",
"validations": [],
"array": false,
"default_value": null
},
{
"name": "gas_price",
"display": "Gas Price",
"description": "",
"type": "decimal",
"validations": [],
"array": false,
"default_value": null
},
{
"name": "gas_limit",
"display": "Gas Limit",
"description": "",
"type": "decimal",
"validations": [],
"array": false,
"default_value": null
},
{
"name": "pubkey",
"display": "Pubkey",
"description": "Value will be retrieved from the chain if available",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
],
"array": false,
"default_value": "02db33d72ee215f1a61e5f4ffa098b9325cc1da6f5c3557974ad0f21a5ec9fe235"
}
]
},
{
"name": "sign_delegate_tx",
"inputs": [
{
"name": "transaction_payload",
"display": "Transaction Payload",
"description": "",
"type": "signed_transaction",
"validations": [
{
"type": "sign_payload",
"options": {}
}
],
"array": false,
"default_value": null,
"signers": [
"cosmos1u85upk2v7pr65g0wv2976zleu6v8qjl9qprvzl"
],
"transaction_payload": "7b226d65737361676573223a5b7b227479706555726c223a222f636f736d6f732e7374616b696e672e763162657461312e4d736744656c6567617465222c2276616c7565223a7b2264656c656761746f7241646472657373223a22636f736d6f733175383575706b3276377072363567307776323937367a6c6575367638716a6c39717072767a6c222c2276616c696461746f7241646472657373223a22636f736d6f7376616c6f7065723174666c6b33306d71357667716a646c7939326b6b686871337261657632686e7a366565746533222c22616d6f756e74223a7b2264656e6f6d223a227561746f6d222c22616d6f756e74223a2232303030303030227d7d7d5d2c22666565223a7b22616d6f756e74223a5b7b22616d6f756e74223a2235313037222c2264656e6f6d223a227561746f6d227d5d2c22676173223a22323034323434227d2c226d656d6f223a22227d",
},
{
"name": "signatures",
"display": "Signatures",
"description": "",
"type": "array_of_signatures",
"validations": [],
"array": true,
"default_value": null,
"element_type": "signature_data",
"signers": [
"cosmos1u85upk2v7pr65g0wv2976zleu6v8qjl9qprvzl"
],
"transaction_payload": "7b226d65737361676573223a5b7b227479706555726c223a222f636f736d6f732e7374616b696e672e763162657461312e4d736744656c6567617465222c2276616c7565223a7b2264656c656761746f7241646472657373223a22636f736d6f733175383575706b3276377072363567307776323937367a6c6575367638716a6c39717072767a6c222c2276616c696461746f7241646472657373223a22636f736d6f7376616c6f7065723174666c6b33306d71357667716a646c7939326b6b686871337261657632686e7a366565746533222c22616d6f756e74223a7b2264656e6f6d223a227561746f6d222c22616d6f756e74223a2232303030303030227d7d7d5d2c22666565223a7b22616d6f756e74223a5b7b22616d6f756e74223a2235313037222c2264656e6f6d223a227561746f6d227d5d2c22676173223a22323034323434227d2c226d656d6f223a22227d",
"signing_payload": "31a9a1e09389b219435eaf2b0dcbab6a1d6950d95545564be627f86c7dfed956",
"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
}
]
}
]
}
],
"data": {
"delegator_address": "cosmos1u85upk2v7pr65g0wv2976zleu6v8qjl9qprvzl",
"validator_address": "cosmosvaloper1tflk30mq5vgqjdly92kkhhq3raev2hnz6eete3",
"amount": "2.0",
"memo": "",
"gas_price": null,
"gas_limit": null,
"delegate_transaction": {
"raw": "7b226d65737361676573223a5b7b227479706555726c223a222f636f736d6f732e7374616b696e672e763162657461312e4d736744656c6567617465222c2276616c7565223a7b2264656c656761746f7241646472657373223a22636f736d6f733175383575706b3276377072363567307776323937367a6c6575367638716a6c39717072767a6c222c2276616c696461746f7241646472657373223a22636f736d6f7376616c6f7065723174666c6b33306d71357667716a646c7939326b6b686871337261657632686e7a366565746533222c22616d6f756e74223a7b2264656e6f6d223a227561746f6d222c22616d6f756e74223a2232303030303030227d7d7d5d2c22666565223a7b22616d6f756e74223a5b7b22616d6f756e74223a2235313037222c2264656e6f6d223a227561746f6d227d5d2c22676173223a22323034323434227d2c226d656d6f223a22227d",
"signing_payload": "31a9a1e09389b219435eaf2b0dcbab6a1d6950d95545564be627f86c7dfed956",
"signed": null,
"hash": null,
"status": null,
"error": null,
"signatures": null,
"block_time": null
},
"pubkey": "02db33d72ee215f1a61e5f4ffa098b9325cc1da6f5c3557974ad0f21a5ec9fe235"
},
"protocol": "cosmos",
"network": "testnet",
"created_at": "2023-02-28T10:45:13.156Z",
"updated_at": "2023-02-28T10:50:21.660Z"
}