Skip to content

Conversation

@PietDuijnstee
Copy link
Contributor

Add working examples demonstrating how to fund an Earn Account with gas sponsorship, where users sign off-chain and a sponsor pays the gas fees.

Python Example:

  • Uses compass_api_sdk with web3.py for signing
  • Demonstrates EIP-712 off-chain signing with eth_account
  • Successfully tested with 0.1 USDC transfer on Base

TypeScript Example:

  • Uses @compass-labs/api-sdk with viem for wallet management
  • Uses @metamask/eth-sig-util for EIP-712 signing (handles TypeScript SDK camelCase type keys)
  • Normalizes EIP712Domain casing to match standard
  • Successfully tested with 0.1 USDC transfer on Base

Key Implementation Details:

  • Step 1 (approve_transfer): One-time Permit2 approval per token
  • Step 2 (earn_transfer): Gas-sponsored deposit to Earn Account
  • Owner signs off-chain (no gas cost)
  • Sender broadcasts transaction and pays gas
  • Requires spender parameter when using gas sponsorship for deposits

Both examples include:

  • Environment configuration with .env.example
  • Clear step-by-step comments with SNIPPET markers
  • Error handling and transaction confirmation
  • BaseScan links for transaction verification

🤖 Generated with Claude Code

Add working examples demonstrating how to fund an Earn Account with gas sponsorship, where users sign off-chain and a sponsor pays the gas fees.

**Python Example:**
- Uses compass_api_sdk with web3.py for signing
- Demonstrates EIP-712 off-chain signing with eth_account
- Successfully tested with 0.1 USDC transfer on Base

**TypeScript Example:**
- Uses @compass-labs/api-sdk with viem for wallet management
- Uses @metamask/eth-sig-util for EIP-712 signing (handles TypeScript SDK camelCase type keys)
- Normalizes EIP712Domain casing to match standard
- Successfully tested with 0.1 USDC transfer on Base

**Key Implementation Details:**
- Step 1 (approve_transfer): One-time Permit2 approval per token
- Step 2 (earn_transfer): Gas-sponsored deposit to Earn Account
- Owner signs off-chain (no gas cost)
- Sender broadcasts transaction and pays gas
- Requires spender parameter when using gas sponsorship for deposits

Both examples include:
- Environment configuration with .env.example
- Clear step-by-step comments with SNIPPET markers
- Error handling and transaction confirmation
- BaseScan links for transaction verification

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ElisabethDuijnstee ElisabethDuijnstee merged commit 31ff3d5 into main Jan 8, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants