Overview
This guide teaches you how to sign EVM transactions using Dynamic’s Node SDK. You’ll learn how to prepare transactions, sign them securely, and send them to the blockchain.Prerequisites
Before you begin, make sure you have:Step 1: Set Up Your Environment
First, install the required dependencies:Step 2: Prepare Your Transaction
Create a transaction using viem’s transaction preparation utilities:Step 3: Key Share Management for Signing
The approach for signing transactions depends on how you created your wallet:With Automatic Backup (Recommended)
If you created your wallet withbackUpToClientShareService: true
, you can sign directly without retrieving key shares:
With Manual Backup
If you created your wallet withbackUpToClientShareService: false
, you must retrieve and provide external key shares:
- If your wallet was created without a password, omit the
password
parameter - If your wallet was created with a password, you must provide it for all operations
- The password parameter is always optional in the API, but required if the wallet is password-protected
Step 4: Send the Transaction
Send the signed transaction to the network:Complete Example: Send ETH
Here’s a complete example that sends ETH from one address to another:Step 5: Handle Transaction Errors
Implement proper error handling for transaction signing and sending:Best Practices
- Gas Estimation: Always let viem estimate gas automatically unless you have specific requirements
- Nonce Management: Use viem’s transaction preparation to handle nonces automatically
- Error Handling: Implement comprehensive error handling for different failure scenarios
- Transaction Monitoring: Monitor transaction status after sending
- Security: Never expose key shares in client-side code