Skip to main content

Using the Staking API

Authentication

Read about the authentication HERE

Click here to view the list of endpoints for the Staking API
info

The endpoints for the Staking API are located at the following URLs:

Avalanche

  • https://avalanche-slate.datahub.figment.io/api/v1/flows
  • https://avalanche-slate.datahub.figment.io/api/v1/flows/[:flow_id]/next

Ethereum

  • https://eth-slate.datahub.figment.io/api/v1/flows
  • https://eth-slate.datahub.figment.io/api/v1/flows/[:flow_id]/next

NEAR

  • https://near-slate.datahub.figment.io/api/v1/flows
  • https://near-slate.datahub.figment.io/api/v1/flows/[:flow_id]/next

Polkadot

  • https://polkadot-slate.datahub.figment.io/api/v1/flows
  • https://polkadot-slate.datahub.figment.io/api/v1/flows/[:flow_id]/next

Solana

  • https://solana-slate.datahub.figment.io/api/v1/flows
  • https://solana-slate.datahub.figment.io/api/v1/flows/[:flow_id]/next

Initialize a Flow

Send an HTTP POST request to the /flows endpoint to start a new flow. The JSON needed to start a new flow must contain the following:

  • flow: An object containing the following fields:
    • network_code: The network used to create the flow (ex. ethereum).
    • chain_code: The chain used to create the flow (ex. mainnet, testnet, etc...).
    • operation: A valid flow operation (ex. staking, transfer, etc...).
    • version: The API version to use. Currently v1.
Example JSON payload for the Staking API to initialize a new flow
{
"flow": {
"network_code": "near",
"chain_code": "testnet",
"operation": "staking",
"version": "v1"
}
}

Example Requests

info

In example requests, the text API-KEY must be replaced with your actual credentials for it to function. Similarly, you would need to replace the value of the constant API_KEY in any code examples.

Example curl request
curl -X POST https://near-slate.datahub.figment.io/api/v1/flows \
-H 'Content-Type: application/json' \
-H 'Authorization: API-KEY' \
-d '{
"flow": {
"network_code": "near",
"chain_code": "testnet",
"operation": "staking",
"version": "v1"
}
}'
Click to view example response
info

The name and inputs for next actions are always in the actions array of the response.

Example JSON response when creating a new flow for staking on NEAR
{
"id": "e4c08fa4-6e4e-4f00-934d-6cd23c7f2c26",
"state": "initialized",
"actions": [
{
"name": "create_delegate_tx",
"inputs": [
{
"name": "delegator_address",
"display": "Delegator Address",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
},
{
"type": "account_balance",
"options": {
"on": "with_on_chain_validations",
"greater_than_or_equal_to": null
}
}
]
},
{
"name": "delegator_pubkey",
"display": "Delegator Pubkey",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
}
]
},
{
"name": "validator_address",
"display": "Validator Address",
"description": "",
"type": "string",
"validations": [
{
"type": "presence",
"options": {}
},
{
"type": "is_validator",
"options": {
"on": "with_on_chain_validations"
}
}
]
},
{
"name": "amount",
"display": "Amount",
"description": "",
"type": "decimal",
"validations": [
{
"type": "presence",
"options": {}
},
{
"type": "numericality",
"options": {
"greater_than": 0
}
}
]
},
{
"name": "max_gas",
"display": "Max Gas",
"description": "",
"type": "decimal",
"validations": []
}
]
}
],
"data": {
"delegator_address": null,
"delegator_pubkey": null,
"validator_address": null,
"amount": null,
"max_gas": null,
"delegate_transaction": null
},
"network_code": "near",
"chain_code": "testnet",
"created_at": "2022-08-04T23:17:50.794Z",
"updated_at": "2022-08-04T23:17:50.794Z"
}

Continue a Flow

Once a flow is initialized, you will need to specify the flow ID in front of the /next endpoint, also sending the correct action name and inputs in the request body to continue with the flow.

Using the flow ID from the above response to illustrate, we would then need to supply the name of the action to take, along with the inputs: In this case, the delegator_address, delegator_pubkey, validator_address and the amount (the max_gas is optional):

Example curl request to continue a NEAR staking flow
curl -X POST https://near-slate.figment.io/api/v1/flows/e4c08fa4-6e4e-4f00-934d-6cd23c7f2c26/next \
-H 'Content-Type: application/json' \
-H 'Authorization: API-KEY' \
-d '{
"name": "create_delegate_tx",
"inputs": {
"delegator_address": "slate-demo.testnet",
"delegator_pubkey": "ed25519:5QA46X6NkNmsFdu9xWVBaLNowh9gGeF1c5r9u6NcxaLY",
"validator_address": "01node.pool.f863973.m0",
"amount": "25",
"max_gas": null,
}
}'
Click to view example response
info

The name and inputs for next actions are always in the actions array of the response.

Example JSON response when continuing a flow for staking on NEAR
{
"id": "e4c08fa4-6e4e-4f00-934d-6cd23c7f2c26",
"state": "delegate_tx_signature",
"actions": [
{
"name": "refresh_delegate_tx",
"inputs": []
},
{
"name": "sign_delegate_tx",
"inputs": [
{
"name": "transaction_payload",
"display": "Transaction Payload",
"description": "",
"type": "signed_transaction",
"validations": [],
"signers": ["ed25519:5QA46X6NkNmsFdu9xWVBaLNowh9gGeF1c5r9u6NcxaLY"],
"transaction_payload": "12000000736c6174652d64656d6f2e746573746e657400415d57cdf21d28e35e0cfa864e895c18b4bc6a711642d38eb6762af81ec1cf3901cc1038fc5700001600000030316e6f64652e706f6f6c2e663836333937332e6d3087c719f49ff474c544c29e6207475f427402b1eac13ae0645dc65408a18791c00100000002110000006465706f7369745f616e645f7374616b65020000007b7d00e057eb481b0000000000b9340332b7f4ad140000000000"
},
{
"name": "signatures",
"display": "Signatures",
"description": "",
"type": "array_of_signatures",
"validations": [],
"signers": ["ed25519:5QA46X6NkNmsFdu9xWVBaLNowh9gGeF1c5r9u6NcxaLY"],
"transaction_payload": "12000000736c6174652d64656d6f2e746573746e657400415d57cdf21d28e35e0cfa864e895c18b4bc6a711642d38eb6762af81ec1cf3901cc1038fc5700001600000030316e6f64652e706f6f6c2e663836333937332e6d3087c719f49ff474c544c29e6207475f427402b1eac13ae0645dc65408a18791c00100000002110000006465706f7369745f616e645f7374616b65020000007b7d00e057eb481b0000000000b9340332b7f4ad140000000000",
"signing_payload": "64ae444f52f75feca6a1720db0fa58f9687c7855834cf8573b4e4f7c15380a4a"
}
]
}
],
"data": {
"delegator_address": "slate-demo.testnet",
"delegator_pubkey": "ed25519:5QA46X6NkNmsFdu9xWVBaLNowh9gGeF1c5r9u6NcxaLY",
"validator_address": "01node.pool.f863973.m0",
"amount": "25.0",
"max_gas": null,
"delegate_transaction": {
"raw": "12000000736c6174652d64656d6f2e746573746e657400415d57cdf21d28e35e0cfa864e895c18b4bc6a711642d38eb6762af81ec1cf3901cc1038fc5700001600000030316e6f64652e706f6f6c2e663836333937332e6d3087c719f49ff474c544c29e6207475f427402b1eac13ae0645dc65408a18791c00100000002110000006465706f7369745f616e645f7374616b65020000007b7d00e057eb481b0000000000b9340332b7f4ad140000000000",
"signing_payload": "64ae444f52f75feca6a1720db0fa58f9687c7855834cf8573b4e4f7c15380a4a",
"signed": null,
"hash": "7n1tkXScgTRWmSYm2ezf9zMXsEdfKB2XFZ89a3Zt1BHK",
"status": null,
"error": null,
"signatures": null
}
},
"network_code": "near",
"chain_code": "testnet",
"created_at": "2022-08-04T23:55:57.932Z",
"updated_at": "2022-08-05T00:05:34.957Z"
}

Staking API Webhooks

You can add, remove, update and list webhooks with the /webhook_endpoints endpoint. The Staking API Webhooks endpoint works alongside the Staking API to manage your webhooks, so that you can be notified when Staking API events occur.

Click to view the list of URLs for Staking API Webhooks
note

The endpoints for this API are located at:

  • https://avalanche-slate.datahub.figment.io/api/v1/webhook_endpoints
  • https://eth-slate.datahub.figment.io/api/v1/webhook_endpoints
  • https://near-slate.datahub.figment.io/api/v1/webhook_endpoints
  • https://polkadot-slate.datahub.figment.io/api/v1/webhook_endpoints
  • https://solana-slate.datahub.figment.io/api/v1/webhook_endpoints

Create a New Webhook Endpoint

Send a POST request to create a new webhook endpoint. Each webhook is identified by a sequential number. Currently when a webhook ID has been deleted it cannot be reused.

You will only be provided with the secret when you first create a webhook.

Remember to capture this data!

Example Requests

Example curl request POST /webhook_endpoints
curl -X POST 'https://eth-slate.datahub.figment.io/api/v1/webhook_endpoints' \
-H 'Authorization: API-KEY' \
-H 'Content-Type: application/json' \
-d '{
"webhook_endpoint": {
"target_url": "https://example.com/my/endpoint",
"event_types": ["*"],
"enabled": "false"
}
}'
Example JSON response
{
"id": 16,
"event_types": [],
"target_url": "https://example.com/my/endpoint",
"enabled": true,
"object": "webhook_endpoint",
"created": "2022-07-26T19:27:12.647Z",
"secret": "whsec_B8sidV4Bm8NnstMuP3a9TSGYov... [REDACTED]"
}

Retrieve Webhook Endpoints

All Webhook Endpoints

Send a GET request to retrieve details for all of your webhook endpoints.

Example Requests

Example curl request GET /webhook_endpoints
curl -X GET 'https://eth-slate.datahub.figment.io/api/v1/webhook_endpoints' \
-H 'Authorization: API-KEY'
Example JSON response
{
"object": "list",
"url": "/api/v1/webhook_endpoints",
"has_more": false,
"data": [
{
"id": 16,
"event_types": ["*"],
"target_url": "https://example.com/my/endpoint",
"enabled": true,
"object": "webhook_endpoint",
"created": "2022-07-26T19:27:12.647Z"
},
{
"id": 15,
"event_types": ["*"],
"target_url": "https://example.com/my/new/endpoint",
"enabled": false,
"object": "webhook_endpoint",
"created": "2022-07-26T18:20:21.849Z"
}
]
}

Individual Webhook Endpoint

Send a GET request, including the webhook ID number in the request URL, to retreive details for an individual webhook endpoint.

Example Requests

Example curl request GET /webhook_endpoints/[:webhook_endpoint_id]
curl -X GET 'https://eth-slate.datahub.figment.io/api/v1/webhook_endpoints/15' \
-H 'Authorization: API-KEY'
Example JSON response for /webhook_endpoints/15
{
"object": "list",
"url": "/api/v1/webhook_endpoints",
"has_more": false,
"data": [
{
"id": 15,
"event_types": ["*"],
"target_url": "https://example.com/my/endpoint",
"enabled": true,
"object": "webhook_endpoint",
"created": "2022-07-26T18:20:21.849Z"
}
]
}

Update Webhook Endpoint

You can send a PUT request to update details for an existing webhook endpoint.

Example Requests

Example curl request PUT /webhook_endpoints/[:webhook_endpoint_id]
curl -X PUT 'https://eth-slate.datahub.figment.io/api/v1/webhook_endpoints/15' \
-H 'Authorization: API-KEY' \
-H 'Content-Type: application/json' \
--data '{
"webhook_endpoint": {
"target_url": "https://example.com/my/new/endpoint",
"event_types": ["*"],
"enabled": "true"
}
}'
Example JSON response
{
"id": 15,
"event_types": ["*"],
"target_url": "https://example.com/my/new/endpoint",
"enabled": true,
"object": "webhook_endpoint",
"created": "2022-07-26T19:27:12.647Z"
}

Delete an Existing Webhook Endpoint

You can send a DELETE request, including the webhook ID number in the request URL, to delete a webhook endpoint.

Example Requests

DELETE /webhook_endpoints/[:webhook_endpoint_id]
curl -X PUT 'https://eth-slate.datahub.figment.io/api/v1/webhook_endpoints/15' \
-H 'Authorization: API-KEY'
Example response
204 - No Content
info

This response does not contain any JSON. Status Code 204 indicates a successful deletion.

API Reference

View the full Staking API reference HERE

View the full Webhooks API reference HERE

See the Guide Working With Staking API Flows for more details about using the Staking API.