Overview
This guide covers EVM-specific implementation details for delegating wallets on Linea and Ethereum networks. Both networks follow the same ERC20 approval pattern with slight differences in gas costs and confirmation times.Use the
/v1/delegation/evm/post-approval endpoint for both Linea and Ethereum delegations.Supported EVM Networks
- Linea
- Ethereum
Network Name: Linea
Chain ID: 59144 (0xe708)
RPC URL: https://rpc.linea.build
Block Explorer: https://lineascan.build
Currencies: USDC, USDTAdvantages:
- Significantly lower gas fees than Ethereum mainnet
- Faster block times (~2-3 seconds)
- Primary network recommended for most integrations
- US routing available with
x-us-env: trueheader
ERC20 Approval Pattern
EVM delegation uses the standard ERC20approve() function to grant spending authority.
The approve() Function
spender: Platform’s smart contract address that will spend tokensamount: Maximum amount the spender can transfer (in token’s smallest unit)
true if approval succeeded
How It Works
1
User Calls approve()
User’s wallet calls the
approve() function on the token contract (USDC or USDT)2
Allowance Updated
Token contract updates the allowance mapping:
3
Platform Can Spend
Platform’s smart contract can now call
transferFrom() to spend up to the approved amount4
Allowance Decreases
Each time platform spends, the allowance decreases by the spent amount
Implementation
Contract Addresses
Obtain contract addresses dynamically by calling the chain configuration endpoint before starting the delegation flow:Recommended: Always fetch addresses dynamically using
GET /v1/delegation/chain/config. This ensures you have the latest contract addresses, especially after platform upgrades or network migrations.Frontend Implementation
SIWE (Sign-In with Ethereum)
SIWE is the standard format for proving wallet ownership through message signing.SIWE Message Format
Field Descriptions
| Field | Required | Description | Example |
|---|---|---|---|
domain | Yes | Domain requesting signature | yourplatform.com |
address | Yes | User’s Ethereum address | 0x3a11a86cf... |
statement | No | Human-readable statement | Prove wallet ownership for delegation |
uri | Yes | Full URI of requesting application | https://yourplatform.com |
version | Yes | SIWE version (always “1”) | 1 |
chainId | Yes | Blockchain chain ID | 59144 (Linea) or 1 (Ethereum) |
nonce | Yes | Random string to prevent replay attacks | abc123xyz789 |
issuedAt | Yes | ISO 8601 timestamp | 2024-10-08T12:00:00Z |
expirationTime | No | ISO 8601 timestamp when signature expires | 2024-10-08T12:30:00Z |
SIWE Implementation
Gas Optimization
Check Existing Allowance
Before requesting a new approval, check if sufficient allowance already exists:Gas Price Strategies
- Standard
- Custom Gas Price
- Gas Estimation
Let wallet handle gas price estimation (recommended):
Submit to API
After collecting all data from the blockchain, submit to the EVM-specific endpoint:API Request
POST /v1/delegation/evm/post-approval
Validation Rules
The API performs strict EVM-specific validation:Address Format
Address Format
- Must start with
0x - Must be exactly 42 characters long
- Must contain only hexadecimal characters (0-9, a-f)
- Case-insensitive, but checksummed addresses are preferred
0x3a11a86cf218c448be519728cd3ac5c741fb3424
Invalid: 3a11a86cf218c448be519728cd3ac5c741fb3424 (missing 0x)Transaction Hash
Transaction Hash
- Must start with
0x - Must be exactly 66 characters long
- Must contain only hexadecimal characters
- Must be a confirmed transaction on the specified network
0xb92de09d893e8162b0861c0f7321f68df02212efbc58f208839ae3f176d89638Signature Hash
Signature Hash
- Must start with
0x - Must be exactly 132 characters long
- Must contain only hexadecimal characters
- Must be valid ECDSA signature that recovers to the provided address
0x2039b9765a4df76e8bae80f3bbc640e8ae6acc81f7a5cc96fe91ccc1844b6f7d4c3e8f1a2b...SIWE Message
SIWE Message
- Must follow SIWE format exactly
- Must contain the provided address
- Must contain correct chain ID for network
- Must not be expired (check expirationTime if present)
Error Handling
Common EVM Errors
API Error Responses
| Status | Error | Cause | Solution |
|---|---|---|---|
| 400 | Invalid address format | Address doesn’t match EVM format | Ensure address starts with 0x and is 42 chars |
| 400 | Invalid transaction hash | Transaction hash not found or wrong format | Wait for confirmation, verify network |
| 400 | Invalid signature | Signature doesn’t match address | Re-sign message, ensure correct wallet |
| 400 | Expired token | Delegation token expired | Generate new token from Step 1 |
| 400 | SIWE validation failed | Message format incorrect | Use exact SIWE format |
| 429 | Rate limited | Too many requests | Wait and retry with exponential backoff |
Testing
Test on Linea Testnet
Before going to production, test on Linea Goerli testnet:- Linea Goerli Faucet: https://faucet.goerli.linea.build
- Goerli ETH Faucet: https://goerlifaucet.com
