This example demonstrates how to use CDP (Coinbase Developer Platform) Wallet to securely sign transactions in OpenZeppelin Relayer.
- A CDP account - Sign up here
- Rust and Cargo installed
- Git
- Docker
- Docker Compose
Clone this repository to your local machine:
git clone https://github.com/OpenZeppelin/openzeppelin-relayer
cd openzeppelin-relayer- Log in to CDP Portal
- Create a new project if you haven't already
- Note down your project details - you'll need these later
- Go to the API Keys section in your project dashboard.
- Create a new Secret API Key.
- Save both the API Key ID and Secret - you'll need these for configuration.
- Note: The API Key Secret is only shown once, make sure to save it securely.
- In CDP Portal, go to the Wallets tab, then Server Wallets.
- Generate a new Wallet Secret if needed.
- Create a new EVM EOA Wallet using either our REST API or an official CDP SDK
- Note down the following details:
- EVM Account Address
Create an environment file by copying the example:
cp examples/evm-cdp-signer/.env.example examples/evm-cdp-signer/.envEdit the .env file and update the following variables:
CDP_API_KEY_SECRET=your_api_key_secret
CDP_WALLET_SECRET=your_wallet_secretEdit the config.json file and update the following variables:
{
"signers": [
{
"id": "cdp-signer-evm",
"type": "cdp",
"config": {
"api_key_id": "YOUR_API_KEY_ID",
"api_key_secret": {
"type": "env",
"value": "CDP_API_KEY_SECRET"
},
"wallet_secret": {
"type": "env",
"value": "CDP_WALLET_SECRET"
},
"account_address": "0xYOUR_EVM_ACCOUNT_ADDRESS"
}
}
]
}Generate random keys for API authentication and webhook signing:
# Generate API key
cargo run --example generate_uuid
# Generate webhook signing key
cargo run --example generate_uuidAdd these to your .env file:
WEBHOOK_SIGNING_KEY=generated_webhook_key
API_KEY=generated_api_keyUpdate the examples/evm-cdp-signer/config/config.json file with your webhook configuration:
- For testing, get a webhook URL from Webhook.site
- Update the config file:
{
"notifications": [
{
"url": "your_webhook_url"
}
]
}Start the service with Docker Compose:
docker compose -f examples/evm-cdp-signer/docker-compose.yaml up- The service exposes a REST API
- You can test it using curl or any HTTP client:
curl -X GET http://localhost:8080/api/v1/relayers \
-H "Content-Type: application/json" \
-H "AUTHORIZATION: Bearer $API_KEY"If you encounter issues:
- Verify your CDP credentials are correct
- Check the service logs for detailed error messages
- Verify the transaction format matches the expected schema
- Ensure your CDP wallet has sufficient permissions for signing