Skip to main content
Coinbase Staking API empowers developers to deliver a fully-featured staking experience in their applications using one common interface across protocols. This quickstart shows you how to stake Hoodi (an Ethereum testnet) ETH to our best-in-class staking infrastructure using the Coinbase Staking API.

What you will learn

  • Installing the CDP SDK
  • How to check your stakeable balance
  • How to create a transaction to stake Hoodi ETH
  • How to sign and broadcast a staking transaction

1. Prerequisites

The Coinbase Typescript SDK requires Node.js version 18+. To verify your Node version:

2. API Key Setup

To use the CDP SDK, you need a CDP secret API key. If you need to create one, follow this guide. Once you have the key, you can either save it as a file on your filesystem (if you downloaded it) or use the key details as environment variables. You will need to reference this later in your code.
Optional API Key File DownloadFor enhanced security, API key files are no longer automatically downloaded. If you need to reference your API key via file path in your code, click the Download API key button in the modal to save the key file. Otherwise, you can copy the key details directly from the modal and use them as environment variables (recommended for better security).

3. Create a Workspace

In your preferred shell, create a new directory:

4. Install the CDP SDK

Install the CDP SDK using your preferred package manager:

5. Create a Staking Transaction

To proceed with the stake example below, you need some Hoodi ETH in your wallet. If you don’t have any, you can request some from the Ethereum Hoodi Faucet.
Create a new file named stake.ts and paste the code block below:
stake.ts

Note

  • Be sure to replace the placeholder values with your own for:
Then run the code to create a staking transaction:
The transaction that was generated is an unsigned transaction. This still needs to be signed and broadcasted to the network to stake successfully. See the next section for instructions on how to sign and broadcast the transaction.

6. Sign and Broadcast your Staking Transaction

The previous step generated an unsigned transaction. To stake successfully, the transaction needs to be signed and broadcasted to the network. Signing and broadcasting functionality is added to the example from above. The additional lines are highlighted for clarity.
showLineNumbers stake.ts

Note

  • Be sure to replace the placeholder values with your own for:
Run the code:
You should see the transaction being created, signed, and then broadcast to the network:
Visit the Etherscan block explorer to view the finalized transaction after it has been broadcasted. Testnet transactions may take up to a minute to be confirmed by a block explorer.

Next Steps

Congratulations! You’ve used the CDP SDK to stake your first ETH on the Holesky testnet. See also: