This example demonstrates how to use Turnkey Wallet Private Key to securely sign transactions in OpenZeppelin Relayer.
- A Turnkey 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 Turnkey Console
- Create a new organization if you haven't already
- Note down your
Organization ID- you'll need this later
- Go to the User details -> API Credentials section in Turnkey Console
- Create a new API credential pair
- Save both the public and private keys - you'll need these for configuration
- Note: The private key is only shown once, make sure to save it securely
- In Turnkey Console, go to Wallets section
- Click "Create private key"
- Choose the following settings:
- Curve type: ED25519
- Asset Address type: Solana
- Complete the api key creation process
- Note down the following details:
- Private Key ID
- Public Key
Create an environment file by copying the example:
cp examples/solana-turnkey-signer/.env.example examples/solana-turnkey-signer/.envEdit the .env file and update the following variables:
TURNKEY_API_PRIVATE_KEY=your_api_private_keyEdit the config.json file and update the following variables:
{
"signers": [
{
"id": "turnkey-signer-solana",
"type": "turnkey",
"config": {
"api_public_key": "your_api_public_key",
"organization_id": "your_organization_id",
"private_key_id": "your_private_key_id",
"public_key": "your_public_key"
}
}
]
}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/solana-turnkey-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/solana-turnkey-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 YOUR_API_KEY"If you encounter issues:
- Verify your Turnkey credentials are correct
- Check the service logs for detailed error messages
- Verify the transaction format matches the expected schema