What you will learn
- Installing the CDP SDK
- How to check your stakeable balance
- How to create a transaction to stake Holesky ETH
- How to sign and broadcast a staking transaction
1. Prerequisites
- TypeScript
- Go
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, place it on your filesystem. You will need to reference this file path later in your code.3. Create a Workspace
In your preferred shell, create a new directory:4. Install the CDP SDK
- TypeScript
- Go
Install the CDP SDK using your preferred package manager:
5a. Create a Staking Transaction using an External Address
To proceed with the stake example below, you need some Holesky ETH in your wallet. If you don’t have any, you can request some from the Ethereum Holesky Faucet.- TypeScript
- Go
Create a new file named NoteThen run the code to create a staking transaction:
stake.ts and paste the code block below:- Be sure to replace the placeholder values with your own for:
Sample output
Sample output
5b. Create a Staking Transaction using a Wallet Address
- TypeScript
Create a new file named NoteThen run the code to create a staking transaction:
stake.ts and paste the code block below:- Be sure to replace the placeholder values with your own for:
Sample output
Sample output
Note
- To reuse the wallet created in the steps above, see Re-instantiating a Wallet with the CDP SDK.
- Network congestion can sometimes delay a transaction, which can cause the funding or stake transaction to fail.
6. [Optional]: Sign and Broadcast your Staking Transaction (External Address only)
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.- TypeScript
- Go
- Be sure to replace the placeholder values with your own for:
Sample output
Sample output
You should see the transaction being created, signed, and then broadcast to the network: