Stake Assets - Self-Custody Wallet
Create staking requests with full signing control. See the Guide.
-
Create a staking request by specifying the staking details and sending them to BitGo. The example shows the minimum required parameters for staking ether.
Prerequisites:
- Complete the Get Started guide
- Create Wallets
- Enable staking in your enterprise by contacting sales@bitgo.com
-
Validators must process your staking request before the request is ready for approval and signing. To get notified when staking requests are pending approval, you can Create Webhooks.
-
If you have a policy that requires approval, you must approve the staking request before signing and broadcasting. You cannot approve your own transactions — another admin must approve them.
-
After an admin approves the staking request (or if no approval is required), sign the transactions and send them to BitGo for final signing and broadcasting to the blockchain.
// 1. Create Staking Request
export COIN="<ASSET_ID>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export AMOUNT="<AMOUNT_IN_BASE_UNITS>"
curl -X POST \
https://app.bitgo-test.com/api/staking/v1/$COIN/wallets/$WALLET_ID/requests \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"amount": "'"$AMOUNT"'",
"type": "STAKE"
}'
// 2. Get Request Status (Optional)
export ENTERPRISE_ID="<YOUR_ENTERPRISE_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export WALLET_TYPE="<YOUR_WALLET_TYPE>"
export WALLET_ID="<YOUR_WALLET_ID>"
curl -X GET \
https://app.bitgo-test.com/api/staking/v1/enterprises/$ENTERPRISE_ID/requests/transactions \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"walletType": "'"$WALLET_TYPE"'",
"walletId": "'"$WALLET_ID"'",
"requestType": "STAKE",
"requestStatus": "PENDING_APPROVAL"
}'
// 3. Approve Request (Optional)
export APPROVAL_ID="<APPROVAL_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export OTP="<YOUR_OTP>"
curl -X PUT \
https://app.bitgo-test.com/api/v2/pendingApprovals/$APPROVAL_ID \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"state": "approved",
"otp": "'"$OTP"'"
}'
// 4. Sign and Send Request
// Use the JavaScript SDK for signing (see JavaScript tab)
// 1. Create Staking Request
const stakingWallet = wallet.toStakingWallet();
const stakingRequest = await stakingWallet.stake({
amount: '<AMOUNT_IN_BASE_UNITS>'
});
// 2. Get Request Status (Optional)
// Use webhooks or call the List staking requests endpoint via REST API
// 3. Approve Request (Optional)
const baseCoin = this.bitgoSDK.coin(initialPendingApproval.coin);
const pendingApproval = await baseCoin.pendingApprovals().get({ id: initialPendingApproval.id });
const result = await pendingApproval.approve(params);
// 4. Sign and Send Request
const transactions = await stakingWallet.getTransactionsReadyToSign(stakingRequest.id);
if (!transactions.allSigningComplete && transactions.transactions.length > 0) {
transactions.transactions.forEach((transaction) => {
await stakingWallet.buildSignAndSend({ walletPassphrase: 'walletPassphrase' }, transaction);
});
}
// 1. Create Staking Request Response
{
"id": "b1ee8da1-338f-5179-cbba-2ec9876e49e4",
"requestingUserId": "7193f86d562163111747942efcb908ce",
"type": "STAKE",
"enterpriseId": "1032e75c451052000436831deb797af1",
"walletId": "2032e75g451052000636831abd797bd3",
"walletType": "hot",
"withdrawalAddress": "HLqx4vChmc1X9DSkzds7a2awzV9Vg3NTtR8BVoeCjd1Y",
"coin": "tsol",
"status": "NEW",
"statusModifiedDate": "2022-01-10T14:32:28Z",
"createdDate": "2022-01-10T14:32:28Z",
"delegations": [],
"transactions": [],
"totalStaked": "0",
"amount": "2000000000",
"stakingType": "SOL_STAKE",
"validator": "vgcDar2pryHvMgPkKaZfh8pQy4BJxv7SpwUG7zinWjG",
"objectType": "SOL_STAKE"
}
// 2. Get Request Status Response
{
"requests": [
{
"id": "b1ee8da1-338f-5179-cbba-2ec9876e49e4",
"requestingUserId": "7193f86d562163111747942efcb908ce",
"type": "STAKE",
"enterpriseId": "1032e75c451052000436831deb797af1",
"walletId": "2032e75g451052000636831abd797bd3",
"walletLabel": "My SOL Wallet",
"walletType": "hot",
"withdrawalAddress": "HLqx4vChmc1X9DSkzds7a2awzV9Vg3NTtR8BVoeCjd1Y",
"coin": "tsol",
"status": "READY",
"statusModifiedDate": "2022-01-10T14:32:35Z",
"createdDate": "2022-01-10T14:32:28Z",
"delegations": [
{
"id": "54g06168-f546-58d3-0bc3-67e0f75gd8f6",
"delegationAddress": "6Rcba2kFiqZaKzwTiXb8dkla75gc2Yj8mN4Pdb2f7Xf3",
"validatorAddress": "vgcDar2pryHvMgPkKaZfh8pQy4BJxv7SpwUG7zinWjG",
"withdrawalAddress": "HLqx4vChmc1X9DSkzds7a2awzV9Vg3NTtR8BVoeCjd1Y",
"provider": "Go",
"providerType": "GO",
"delegated": "0",
"coin": "tsol",
"walletId": "2032e75g451052000636831abd797bd3",
"properties": {
"validatorAddress": "vgcDar2pryHvMgPkKaZfh8pQy4BJxv7SpwUG7zinWjG",
"stakingType": "SOL_STAKE",
"type": "SOL",
"coinSymbol": "tsol"
},
"status": "PENDING",
"rewards": "0",
"lockedRewards": "0",
"pendingUnstake": "0",
"pendingStake": "2000000000",
"reserved": "0",
"pendingReserved": "0",
"apy": "5.26",
"unstakingFee": "0",
"unstakingMin": "0",
"unstakeable": false,
"permissionAttributes": {
"staking": {
"enabled": false,
"disabledReason": "Delegation is not active.",
"allowClientToUseOwnValidator": false
},
"unstaking": {
"enabled": false,
"disabledReason": "Delegation is not active."
}
}
}
],
"transactions": [
{
"id": "0cc5d4e7-c195-517b-09cf-343bg907383c",
"stakingRequestId": "b1ee8da1-338f-5179-cbba-2ec9876e49e4",
"delegationId": "54g06168-f546-58d3-0bc3-67e0f75gd8f6",
"createdDate": "2022-01-10T14:32:28Z",
"transactionType": "delegate",
"status": "READY",
"statusModifiedDate": "2022-01-10T14:32:35Z",
"amount": "2000000000",
"txRequestId": "120ged40-c2b2-80e9-c9ec-dc66fg99b3bb"
}
],
"totalStaked": "0",
"amount": "2000000000",
"stakingType": "SOL_STAKE",
"validator": "vgcDar2pryHvMgPkKaZfh8pQy4BJxv7SpwUG7zinWjG",
"objectType": "SOL_STAKE"
}
],
"page": 1,
"totalPages": 1,
"totalElements": 1
}
// 3. Approve Request Response
{
"id": "e055adbc-66a3-4ccd-9a9d-726a05bca0cf",
"coin": "tsol",
"wallet": "2032e75g451052000636831abd797bd3",
"enterprise": "1032e75c451052000436831deb797af1",
"state": "approved",
"approvalsRequired": 1
}
// 4. Sign and Send Request Response
{
"id": "0cc5d4e7-c195-517b-09cf-343bg907383c",
"stakingRequestId": "b1ee8da1-338f-5179-cbba-2ec9876e49e4",
"delegationId": "54g06168-f546-58d3-0bc3-67e0f75gd8f6",
"createdDate": "2022-01-10T14:32:28Z",
"transactionType": "delegate",
"status": "PENDING",
"statusModifiedDate": "2022-01-10T14:32:50Z",
"amount": "2000000000",
"txRequestId": "120ged40-c2b2-80e9-c9ec-dc66fg99b3bb"
}