Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Using CDP for Secure Transaction Signing in OpenZeppelin Relayer

This example demonstrates how to use CDP (Coinbase Developer Platform) Wallet to securely sign transactions in OpenZeppelin Relayer.

Prerequisites

  1. A CDP account - Sign up here
  2. Rust and Cargo installed
  3. Git
  4. Docker
  5. Docker Compose

Getting Started

Step 1: Clone the Repository

Clone this repository to your local machine:

git clone https://github.com/OpenZeppelin/openzeppelin-relayer
cd openzeppelin-relayer

Step 2: Set Up Your CDP Account

  1. Log in to CDP Portal
  2. Create a new project if you haven't already
  3. Note down your project details - you'll need these later

Step 3: Create API Credentials

  1. Go to the API Keys section in your project dashboard.
  2. Create a new Secret API Key.
  3. Save both the API Key ID and Secret - you'll need these for configuration.
  4. Note: The API Key Secret is only shown once, make sure to save it securely.

Step 4: Create a Wallet

  1. In CDP Portal, go to the Wallets tab, then Server Wallets.
  2. Generate a new Wallet Secret if needed.
  3. Create a new EVM EOA Wallet using either our REST API or an official CDP SDK
  4. Note down the following details:
    • EVM Account Address

Step 5: Configure the Relayer Service

Create an environment file by copying the example:

cp examples/evm-cdp-signer/.env.example examples/evm-cdp-signer/.env

Populate CDP API Credentials

Edit the .env file and update the following variables:

CDP_API_KEY_SECRET=your_api_key_secret
CDP_WALLET_SECRET=your_wallet_secret

Populate CDP config

Edit 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 Security Keys

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_uuid

Add these to your .env file:

WEBHOOK_SIGNING_KEY=generated_webhook_key
API_KEY=generated_api_key

Configure Webhook URL

Update the examples/evm-cdp-signer/config/config.json file with your webhook configuration:

  1. For testing, get a webhook URL from Webhook.site
  2. Update the config file:
{
  "notifications": [
    {
      "url": "your_webhook_url"
    }
  ]
}

Step 6: Run the Service

Start the service with Docker Compose:

docker compose -f examples/evm-cdp-signer/docker-compose.yaml up

Step 7: Test the Service

  1. The service exposes a REST API
  2. 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"

Troubleshooting

If you encounter issues:

  1. Verify your CDP credentials are correct
  2. Check the service logs for detailed error messages
  3. Verify the transaction format matches the expected schema
  4. Ensure your CDP wallet has sufficient permissions for signing

Additional Resources