Delegation API

Programmatically stake using our delegation API and validator infrastructure.

White Labeled Staking

Setting up a white label solution with Staked's infrastructure is done in three general steps:

  1. Use our Delegation API to receive a transaction to sign or construct one yourself

  2. Sign the delegation transaction with your private keys

  3. Send the signed delegation transaction back to Staked over the Delegation API or broadcast it to the blockchain yourself

Cosmos - An Example

Before You Get Started - Some Pre-Reqs

  • You have a Cosmos account with some Atoms you want to delegate to Staked. On testnet, you can use our faucet.

  • That account is accessible via the gaiacli keys list on a PC that is or is not internet connected -OR- the account is available on a ledger.

  • Using one of the two methods above, you can sign a transaction with those keys and return the signature via API.

If you would like to run tests initially, use this base url in the API methods below: https://testnet.staked.cloud/api

post
Step 1: Post Delegation Request

https://mainnet.staked.cloud/api/delegations/Cosmos/delegator/:address
Posting to this endpoint lets Staked know you want to delegate to our infrastructure and returns a delegation transaction for you to sign with your private keys.
Request
Response
Path Parameters
address
required
string
Your testnet address
Headers
Content-Type
required
string
application/json
Query Parameters
api_key
required
string
Your testnet API key
Body Parameters
amount
required
string
Amount you want to staked
200: OK
The response contains the gas fee, along with the transaction to be signed.
Delegation Transaction Response
{
"id": 2623,
"address": "cosmos1q7zza2d70wvy3yhzudzxh28spl4fkp29xzma8m",
"chain": "COSMOS",
"attributes": {
"type": "cosmos-sdk/StdTx",
"value": {
"fee": {
"gas": "2796",
"amount": []
},
"msg": [
{
"type": "cosmos-sdk/MsgDelegate",
"value": {
"amount": {
"denom": "muon",
"amount": "100"
},
"delegator_address": "cosmos1q7zza2d70wvy3yhzudzxh28spl4fkp29xzma8m",
"validator_address": "cosmosvaloper18vspjrcxgq66spd5c4s42eg8v7u20wqu9y2u3a"
}
}
],
"memo": "Delegation txn created by Staked: 2019-09-05T22:46:03.392889",
"signatures": null
},
"chain_id": "gaia-13003"
},
"amount": "100",
"created": "2019-09-05T22:46:03",
"status": "CREATED"
}

Step 2: Sign the Delegation Transaction

You now need to the sign delegation transaction you got from step 1.

We assume you have gaiacli and --recover a key with the alias MyKey

Build txn_to_sign.json, manually or with jq:

  • With the json response from step 1, copy the content of attributes into a file txn_to_sign.json.

    -OR-

  • With jq:

    $ curl ... | jq ' .attributes ' > txn_to_sign.json

txn_to_sign.json should look like:

{
"value": {
...
},
"type": "...",
"chain_id": "<testnet_chain_id>"
}

With txn_to_sign.json, run the following, with chain-id from the POST response:

$ gaiacli tx sign delegate_to_sign.json --from=MyKey --chain-id=<testnet_chain_id>

The output will be a nearly identical json as the input, but including signatures:

{
...
"signatures": [
{
"pub_key": {
"type": "tendermint/PubKeySecp256k1",
"value": "<addr>"
},
"signature": "<signature>"
}
],
...
}

We will use this output in the next step!

Step 3: Send Us the Signed Transaction

Given a JSON file txn_signed.json containing the signed transaction from Step 3, rewrap value in attributes. tx_signed.json should look like:

{
"attributes": {
"value": {
...
"signatures": [
...
]
}
}
}

put
Put Signed Transaction

https://mainnet.staked.cloud/api/delegations/COSMOS/delegator/:address/broadcast
This method sends the signed transaction to Staked. After we receive the signed transaction, we broadcast it to the blockchain for you.
Request
Response
Path Parameters
api_key
required
string
Your testnet API key
Headers
Content-Type
required
string
application/json
Body Parameters
required
object
The body should be the JSON of tx_signed.json from above.
200: OK
The delegation was successful!
Congratulations, you delegated to Staked

And that's it! You've delegated ATOMS to Staked. Check out our Reporting API to keep tabs on your stake.

Remember, you don't have to use our Delegation API to implement white label staking, as long as you have the ability to construct a delegation transaction, sign the transaction, and broadcast it to the blockchain.