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

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.

Cosmos

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
Request
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
Response
200: OK
The response contains the gas fee, along with the transaction to be signed.
Delegation Transaction Response
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
Request
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.
Response
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.

Dash

Dash is currently only live on our testnet API. For Dash, we will support 2 masternodes per partner account in a sandbox/testnet environment.

Before You Get Started - Some Pre-Reqs

In order to set up a masternode you'll need to use a Dash faucet to obtain enough DASH to create an address with exactly 1000 Dash and get a Masternode txn_id. There are a number of faucets that give out testnet DASH:

  • http://test.faucet.masternode.io

  • http://faucet.test.dash.crowdnode.io

  • https://test.faucet.dashninja.pl

All instructions in this step assume you are using either the dash command line tool or the debug console in the GUI wallet. If you are using the debug console, remove dash-cli from the beginning of each command mentioned below.

Create two new addresses, the first to hold your masternode collateral and the second to serve as your owner address You can create addresses using the following command:

dash-cli getnewaddress <address-alias>

Example

dash-cli getnewaddress masternode_1_owner

Next, send exactly 1,000 Dash to your collateral address

dash-cli sendtoaddress <address> <amount>

Example

dash-cli sendtoaddress XkGe5utNkxXzsCHtDAXEXRBHXouHamYHBB 1000

Get the transaction id and output index of the transaction you just created (you may need to wait up to 2 minutes until your transaction is added to a block).

dash-cli masternode outputs

Which looks like this:

{
"8960321b0c43a51e35d0226debfc117ae22856c1710af855e7997e3aa9b4ed82": "1",
"053c79483f8b5eab7f53175d3a26dc45c295e3ac213f188237d40f2cd2f84da9": "1",
"370820cef360f0d383200d1d72e6886aaaf16a114b209c4344a866b920c506d1": "1"
}

You will need a payoutAddress which can be generated using the commands above, and can be shared on different masternodes.

post
Step 1: Post Delegation Request

https://testnet.staked.cloud/api/delegations
Use this method to post a delegation request and register a new masternode address.
Request
Response
Request
Path Parameters
key
required
string
Your API Key
Headers
Content-Type
required
string
application/json
Body Parameters
address
required
string
Using example from pre-reqs: "XkGe5utNkxXzsCHtDAXEXRBHXouHamYHBB"
chain
required
string
"Dash"
attributes
required
object
Using example from pre-reqs: { "collateralHash": "8960321b0c43a51e35d0226debfc117ae22856c1710...", "collateralIndex": 1, "payoutAddress": Payout address here }
Response
200: OK

get
Step 2: Check Masternode Status

https://testnet.staked.cloud/api/delegations
Use this method to check the status of your masternode from step 1. The response will be a Delegation object with attributes and a status. When the status is WaitingForSigning, the attributes for the masternode address will include the signMessage attribute to be used in step 3.
Request
Response
Request
Path Parameters
address
required
string
Masternode address you set up previously.
Query Parameters
key
required
string
Your API Key
Response
200: OK

Step 3: Sign Delegation Message

This must be run on wallet/device that holds collateral key. This can be done completely offline (for example, if the user holds collateral keys in a ledger), and the signMessage is the output from above.

signmessage collateralAddress signMessage

Example Response:

H3ub9BATtvuV+zDGdkUQNoUGpaYFr/O1FypmrSmH5WJ0KFRi8T10FSew0EJO/+Ij+OLv4r0rt+HS9pQFsZgc2dE=

put
Step 4: Send Us the Signed Delegation Message

https://testnet.staked.cloud/api/delegations
Finally, send us the signed transaction and we will broadcast it for you!
Request
Response
Request
Path Parameters
address
required
string
Masternode address you set up previously.
Query Parameters
key
required
string
Your API Key
Body Parameters
attributes
required
object
From our example: { "signedTx": Your Signed Delegation Message }
Response
200: OK

The status of the delegation object is now WaitingToSubmit. When the Masternode is synched, the signedTx will be submitted and the status will be Ready.

Boom! You've programmatically set up a Masternode on testnet. Check out the Reporting API to see monitor your position.