Node Provisioning API

Dynamically provision nodes and receive staking transactions to sign.

What is the Node Provisioning API?

The Node Provisioning API allows partners to programmatically spin-up nodes for staking. Partners specify the number of nodes needed and receive a transaction to sign that stakes with those node/s.

Chain

Assets per Node

Ethereum 2.0

32 ETH per Validator

Dash

1,000 DASH per Masternode

Horizen

500 ZEN per Supernode

Keep

100,000 KEEP per Node

Ethereum 2.0

Provision multiple validators with a single API request and submit their deposits through an atomic transaction to our batching contract.

Getting Started

Before sending funds to the deposit contract, you MUST generate an ETH2 key pair to control your funds on the Ethereum 2.0 chain. This is required because Ethereum 2.0 uses BLS, a different form of cryptography than what is used on the current version of Ethereum.

You'll need to generate an ETH2 key pair before sending requests to our API. An ETH2 BLS key pair is the only way to claim ETH2 when transfers are enabled, and can be used for any number of validators.

For the purposes of this walkthrough, we'll use the prysmatic labs validator image to generate a withdrawal key pair. First, you'll need Docker installed, then head over to the command line. Navigate to a testing directory, create a subfolder named "data", and run the following command.

docker run -it -v "$PWD:/data" --network="host" gcr.io/prysmaticlabs/prysm/validator:latest accounts create --keystore-path=/data --password=YourPassword

The above command will generate an ETH2 account and store it in your local filesystem. The command generates a validator address and deposit transaction as well, but all you need is the withdrawal key pair. A withdrawal key pair will be stored in your current working directory.

shardwithdrawalkey
{
"publickey": "844fdf9333b44ffe8b83db3fa09f7c0857235c373c3922c0ef9200bfd8ddcb77ec8419a408fec21d6d579670195f49a2",
...
}

Now, you're ready to provision validators through our API!

The ETH2 API is in Alpha, meaning both endpoints and schema are subject to change. This document should be viewed as a general reference for integration flow in an upcoming stable release. For release notifications, click here.

post
Post Provisioning Request

https://eth2.staging.staked.cloud/api/provisioning_requests/eth2
Provision ETH2 validators in our secure cloud environments. The response contains a unique identifier for the provisioning request, as well as a deposit transaction and public key for each validator.
Request
Response
Request
Query Parameters
api_key
required
string
Your API Key - (Must have ETH2 access)
Body Parameters
attributes
required
object
See below for object schema.
Response
200: OK
{
"uuid": "949f8b0113ac4845863e960cff63a5c1",
"created": "2020-05-08T16:40:02",
...
"attributes": {
"validators": [
{
"cloud": "amazon",
"count": 5,
"index": 1,
"depositInput": "22895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120e0adc3769775d2f56d7f5f0b08a280d29d2ab942c0b36819bd46231e5e8ea8e000000000000000000000000000000000000000000000000000000000000000308d2504147e3a0f5612f52baea44157aef71d8913715826515f9f431b5797a7f8c570c2cbd87814d07ae4a98d5dc3510c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000021288b63da4714a3e67e0578ac05d7000ba1d707ca21d741b344fb1cd55d20000000000000000000000000000000000000000000000000000000000000060acea22cd90a6d0fec2853ef375bece0b6f5f1b05fc794e27ba88854bc692d7372c6c74051bd1876a1bf7b51e72908e010c33551423e5c36c1dcff86daff193d9c5857699a97820e024a8735c37ae2a78f9b555e77b5c0797fb6886c801631415",
"validatorKey": "8d2504147e3a0f5612f52baea44157aef71d8913715826515f9f431b5797a7f8c570c2cbd87814d07ae4a98d5dc3510c"
},
{
"cloud": "amazon",
"count": 5,
"index": 2,
"depositInput": "22895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012053f61469f7100ff426cb0b7b18710b18a3e775c3df8f2740324fd51fa4f8ba84000000000000000000000000000000000000000000000000000000000000003093067b1dd358dd8a628e569e3decb92ad996c2ca7578b89db405abfd0736207f75d69515106b6abf73e1c93409e9cc0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000021288b63da4714a3e67e0578ac05d7000ba1d707ca21d741b344fb1cd55d20000000000000000000000000000000000000000000000000000000000000060b747ea9a0f9c33f8f9c94b994e51e31439a898454b6a479f36f0c9e3d8a43916a6f5399db0ddc0d03c50a0d186da1d150567edc0d3530ed72e65ce4b45fe3b809e6df5753510e934ee1e6278c06694f580d4579d6eb79e62887f889029080c98",
"validatorKey": "93067b1dd358dd8a628e569e3decb92ad996c2ca7578b89db405abfd0736207f75d69515106b6abf73e1c93409e9cc0f"
},
...
],
"withdrawalKey": "b2484e5f4e4410cbcc12117cd922e131576e13d9856fc9bb4c0901383fda7ce42668ecb1ebaba2f8afb5e0afd4f0a0bd"
}
}
JavaScript - Node.js
JavaScript - Node.js
async function postProvisioningRequest() {
const endpoint = "/provisioning_requests/eth2";
try {
var response = await axios.post(STAKED_API_URL + endpoint + `?api_key=${STAKED_API_KEY}`, {
attributes: {
"withdrawalKey": WITHDRAWAL_PUBLIC_KEY,
"validators": [
{
"cloud": "amazon",
"count": 2
}
]
}
});
return response.data.attributes.validators;
} catch (error) {
throw error;
}
}

Submit Transactions to the Batching Contract

The canonical ETH2 deposit contract, used to convert ETH1 to ETH2, only supports one deposit transaction at a time. Since 32 ETH is required for each validator, a depositor with 512 ETH would have to submit and broadcast 16 individual deposit transactions to the deposit contract.

To simplify this process, we have created a batching contract which takes up to 20 deposit transactions at once and submits each to the deposit contract. Integrators can therefore stake up to 640 ETH in one Ethereum transaction, and leave behind the hassle of tracking many individually broadcasted transactions. If you want to stake more than 640 ETH in one transaction please contact us as we have tools to facilitate that as well.

Smart Contract

Goerli Address

Batching Contract

0xb0989486e06b953f0e4b1fe1d692ac3d2c1da43f

The batching contract has an external payable function, batchDeposits, which is used for integrations. The function arguments are passed as an array where the data at [i] represents the arguments for deposit transaction i.

A list of provisioned validators with transaction data was returned in the previous API call. This data is now used to construct a transaction to the batching contract.

JavaScript - Node.js
JavaScript - Node.js
/* Example Validator Response from Provisioning Request
{
"cloud": "amazon",
"validatorKey": "Public key of Generated Validator",
"depositInput": "Deposit Transaction Data"
}
*/
async function submitBatchTransactions(validators) {
var pubkeys = [];
var withdrawal_credentials = [];
var signatures = [];
var deposit_data_roots = [];
for (let i = 0; i < validators.length; i++) {
let decoded = decodeDepositInput(validators[i].depositInput);
pubkeys.push(decoded.pubkey);
withdrawal_credentials.push(decoded.withdrawal_credentials);
signatures.push(decoded.signature);
deposit_data_roots.push(decoded.deposit_data_root);
}
const batchingABI = require("./build/contracts/BatchDeposit_Goerli.json").abi;
const batchingContract = new web3.eth.Contract(batchingABI, BATCHING_CONTRACT_ADDR);
try {
const ether = n => new web3.utils.BN(web3.utils.toWei(n, 'ether'));
const tx = await batchingContract.methods.batchDeposit(
pubkeys,
withdrawal_credentials,
signatures,
deposit_data_roots)
.send({ from: web3.eth.accounts.wallet[0].address, value: ether(web3.utils.toBN(32 * validators.length)), gasPrice: GAS_PRICE, gas: 7999999 });
console.log(tx);
} catch (error) {
console.log(error);
}
}
function decodeDepositInput(data) {
return web3.eth.abi.decodeParameters([
{
"type": "bytes",
"name": "pubkey"
}, {
"type": "bytes",
"name": "withdrawal_credentials"
}, {
"type": "bytes",
"name": "signature"
}, {
"type": "bytes32",
"name": "deposit_data_root"
}],
"0x" + data.substring(8)
);
}

Congratulations! You've provisioned multiple validators with our API and submitted their deposits through an atomic transaction to our batching contract. For release notifications of the API and batching contract, click here.

Dash

Automate provisioning of Dash masternodes.

Getting Started

Masternodes require exactly 1,000 DASH each. For testing purposes please email [email protected] for testnet Dash, or request it in the Dash Discord. Staked will support 2 masternodes per partner account in a testnet environment.

Each masternode requires an unspent transaction output (UTXO) of exactly 1,000 DASH. The address that owns this UTXO is the collateral address.

Instructions below assume use of the dash command line tool or debug console in the GUI wallet. If using the debug console, please remove dash-cli from the beginning of each command.

Create a new address to hold your masternode collateral.

dash-cli getnewaddress <address-alias>

Example

dash-cli getnewaddress masternode_collateral_1

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

dash-cli sendtoaddress <address> <amount>

Example

dash-cli sendtoaddress yTrtvsNuVgezcGmcVyv2n8D2dFeJEHCYhg 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

masternode outputs
schema
{
"tx id": "collateral index"
}
example
{
"3483e20a675d7585f0d3a07579f52551e59854ee6ad88af80492418c75a5d4a2": "1",
...
}

A payout address is also needed and can be generated using the getnewaddress command. A single payout address can be shared across masternodes.

post
Step 1: Post Masternode Provisioning Request

https://testnet.staked.cloud/api/delegations/DASH/delegator/:collateralAddress
Provision a new masternode after sending 1,000 DASH to a collateral address.
Request
Response
Request
Path Parameters
collateralAddress
required
string
Your collateral address
Headers
Content-Type
required
string
application/json
Query Parameters
api_key
required
string
Your api key
Body Parameters
attributes
required
object
Using example from pre-reqs: { "collateralHash": "3483e20a675d7585f0...", "collateralIndex": 1, "payoutAddress": "Payout address here" }
Response
200: OK
{
"id": 2691,
"address": "yTrtvsNuVgezcGmcVyv2n8D2dFeJEHCYhg",
"chain": "DASH",
"attributes": {
"payoutAddress": "yQAt7kYbwZAiWVz9LCVzaox7mxrVBZYNAp",
"collateralHash": "3483e20a675d7585f0d3a07579f52551e59854ee6ad88af80492418c75a5d4a2",
"collateralIndex": 1
},
"created": "2020-06-04T21:23:32",
"status": "CREATED"
}

get
Step 2: Poll Masternode Status

https://testnet.staked.cloud/api/delegations/DASH/delegator/:collateralAddress
Poll the masternode status. The status is initially set as CREATED. Once the masternode registration message is created through Staked's provisioning infrastructure the response will pass the message for signing along with a status of WaitingForSigning.
Request
Response
Request
Path Parameters
collateralAddress
required
string
Your collateral address used previously.
Query Parameters
api_key
required
string
Your API Key
Response
200: OK
Status is "CREATED"
{
"results": [
"id": 2691,
"address": "yTrtvsNuVgezcGmcVyv2n8D2dFeJEHCYhg",
"chain": "DASH",
"attributes": {
"payoutAddress": "yQAt7kYbwZAiWVz9LCVzaox7mxrVBZYNAp",
"collateralHash": "3483e20a675d7585f0d3a07579f52551e59854ee6ad88af80492418c75a5d4a2",
"collateralIndex": 1
},
"created": "2020-06-04T21:23:32",
"status": "CREATED"
],
"page": 1,
"pages": 1,
"per_page": 10,
"total": 1
}
Status is "WaitingForSigning"
{
"results": [
{
"id": 2691,
"address": "yTrtvsNuVgezcGmcVyv2n8D2dFeJEHCYhg",
"chain": "DASH",
"attributes": {
"ipAndPort": "52.10.215.49:19999",
"signMessage": "yQAt7kYbwZAiWVz9LCVzaox7mxrVBZYNAp|1000|yQFVUWVMP5kVM9Rp8oXLScEAsPMB974rPd|yQFVUWVMP5kVM9Rp8oXLScEAsPMB974rPd|d85fcd73cdb916b1dce77e993cbb915b58381d29067d18757550f9a5dfec5de9",
"internalPort": 32419,
"ownerKeyAddr": "yQFVUWVMP5kVM9Rp8oXLScEAsPMB974rPd",
"registerTxId": "03000100012730d8726ddae3434dfec7e66923b01134a1124982e9e71e1a5f79e2575de2a50000000000feffffff0142b19a3b000000001976a914641138d9d61f2b7d8cccd6c29959349549ba5e8388ac00000000d1010000000000a2d4a5758c419204f88ad86aee5498e55125f57975a0d3f085755d670ae283340100000000000000000000000000ffff340ad7314e1f2b210805a79c2e5e453b20ef85d29633c151076c85c86cdb8d2ebf444fbc40c739b190e56a4c2f8ae9d26567bf2b0d3152ff7c435df652866f572af774d11454fe92a6d12b210805a79c2e5e453b20ef85d29633c151076ce8031976a9142a41da2a5517ae71484594d2187c7f99ed20e91e88ac34dec225612f265fb337240197d8f30ba22a6d5ca12547e50a91ff2aec7bedaa00",
"payoutAddress": "yQAt7kYbwZAiWVz9LCVzaox7mxrVBZYNAp",
"collateralHash": "3483e20a675d7585f0d3a07579f52551e59854ee6ad88af80492418c75a5d4a2",
"operatorPubKey": "85c86cdb8d2ebf444fbc40c739b190e56a4c2f8ae9d26567bf2b0d3152ff7c435df652866f572af774d11454fe92a6d1",
"collateralIndex": 1
},
"amount": null,
"created": "2020-06-04T21:23:32",
"status": "WaitingForSigning"
}
],
"page": 1,
"pages": 1,
"per_page": 10,
"total": 1
}

Step 3: Sign Delegation Message

This must be run on the wallet or device that holds collateral key, and can be done completely offline if required. signMessage is returned in the response of the previous step.

signmessage collateralAddress signMessage

Example Output:

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

put
Step 4: Send Us the Signed Delegation Message

https://testnet.staked.cloud/api/delegations/DASH/delegator/:collateralAddress
Finally, send Staked the signed transaction and we will broadcast it to the Dash blockchain!
Request
Response
Request
Path Parameters
collateralAddress
required
string
Masternode collateral address set up previously.
Query Parameters
api_key
required
string
Your API Key
Body Parameters
attributes
required
string
{ "signedTx": "Your Signed Message" }
status
required
string
Set as "WaitingtoSubmit"
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. Check out the Reporting API to monitor your position.