Tip
If you're looking to contribute to the SDK, please see the Contributing Guide.
This module contains the Go CDP SDK, which is a library that provides a client for interacting with the Coinbase Developer Platform (CDP). It includes a CDP Client for interacting with EVM and Solana APIs to create accounts and send transactions, as well as authentication tools for interacting directly with the CDP APIs.
CAUTION: The Go SDK is an autogenerated client library, and as such, does not have the first-class support that the Typescript and Python SDKs have. We recommend using the Typescript or Python SDKs instead, if at all possible.
Refer to CDP's Unified API Reference for more details on the APIs accessed through this SDK.
go get github.com/coinbase/cdp-sdk/goTo start, create a CDP API Key. Save the API Key ID and API Key Secret for use in the SDK. You will also need to create a wallet secret in the CDP Portal create accounts and sign transactions.
See the Go examples directory in the CDP SDK repository for runnable end‑to‑end usage examples.
cdp "github.com/coinbase/cdp-sdk/go"cdp, err := cdp.NewClient(cdp.ClientOptions{
APIKeyID: apiKeyName,
APIKeySecret: apiKeySecret,
WalletSecret: walletSecret,
})response, err := cdp.CreateEvmAccountWithResponse(
ctx,
nil,
openapi.CreateEvmAccountJSONRequestBody{},
)
if err != nil {
return "", err
}
if response.StatusCode() != 201 {
return "", fmt.Errorf("failed to create EVM account: %v", response.Status())
}You can use the faucet function to request testnet ETH or SOL from the CDP.
response, err := cdp.RequestEvmFaucetWithResponse(
ctx,
openapi.RequestEvmFaucetJSONRequestBody{
Address: evmAddress,
Network: openapi.RequestEvmFaucetJSONBodyNetwork("base-sepolia"),
Token: openapi.RequestEvmFaucetJSONBodyToken("eth"),
},
)
if err != nil {
return err
}
if response.StatusCode() != 200 {
return fmt.Errorf("failed to faucet EVM address: %v", response.Status())
}toAddress := common.HexToAddress("0x450B2dC4Ba2a08E58C7ECc3DE48e3C825262caF8")
transaction := types.DynamicFeeTx{
ChainID: big.NewInt(84532),
Nonce: 0,
To: &toAddress,
Value: big.NewInt(10000000000000), // 0.00001 ETH
Data: []byte{},
Gas: 21000,
GasFeeCap: big.NewInt(1000000000), // 1 gwei max fee
GasTipCap: big.NewInt(100000000), // 0.1 gwei max priority fee
}
// Serialize transaction to RLP
rlpTx := types.NewTx(&transaction)
rlpData, err := rlpTx.MarshalBinary()
if err != nil {
return "", err
}
rlpHex := hex.EncodeToString(rlpData)
rlpHex = "0x" + rlpHex
response, err := cdp.SignEvmTransactionWithResponse(
ctx,
evmAddress,
nil,
openapi.SignEvmTransactionJSONRequestBody{
Transaction: rlpHex,
},
)
if err != nil {
return "", err
}
if response.StatusCode() != 200 {
return "", fmt.Errorf("failed to sign transaction: %v", response.Status())
}This SDK also contains simple tools for authenticating REST API requests to the Coinbase Developer Platform (CDP) in the auth/ directory.
This project is licensed under the MIT License - see the LICENSE file for details.
For feature requests, feedback, or questions, please reach out to us in the #cdp-sdk channel of the Coinbase Developer Platform Discord.
If you discover a security vulnerability within this SDK, please see our Security Policy for disclosure information.