LogoLogo
DashboardBlogNode API DocsContact
  • Staking
    • Overview
    • FAQ
  • Ethereum
    • Staking Tutorial
      • API
        • Prerequisites
        • Authenticating with Auth0
        • Setting up a Wallet
        • Get Staking Transaction
        • Signing a Transaction
        • Broadcast Transaction
        • Full Code
    • Staking API Reference
      • Authentication
      • Get Validators
      • Stake Transaction
      • Broadcast Transaction
      • Exit Validators
      • Presigned Exit Request
Powered by GitBook
On this page
  1. Ethereum
  2. Staking Tutorial
  3. API

Get Staking Transaction

Running your first API call

The code snippet below makes a request against Validation Cloud Staking API to obtain the staking transaction that will be signed later on, and broadcasted to the network:

const STAKING_BASE_API_URL = 'https://ethereum-staking.sprd.validationcloud.io/v1/api';
const STAKING_REQUEST_URL = `${STAKING_BASE_API_URL}/ethereum/mainnet/stake_transaction`;

async function createStakeTransaction(token, walletAddress, num) {
  const jsonBody = JSON.stringify({
    num_validators: num,
    wallet_address: walletAddress,
  });

  const response = await fetch(STAKING_REQUEST_URL, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: jsonBody,
  });

  return await response.json();
}
PreviousSetting up a WalletNextSigning a Transaction

Last updated 1 year ago