Skip to content

Add account abstraction examples and test suite #34

Description

@ch4r10t33r

Title

Add account abstraction examples and test suite

Labels

documentation, examples, testing, account-abstraction

Description

Create comprehensive examples and tests demonstrating ERC-4337 account abstraction features in zigeth.

Requirements

Example Programs

examples/aa_01_simple_account.zig

  • Deploy a SimpleAccount
  • Send first UserOperation (with account deployment)
  • Execute subsequent operations
  • Check account balance and nonce

examples/aa_02_sponsored_tx.zig

  • Setup with paymaster service
  • Send gasless transaction
  • Verify user paid 0 gas
  • Show paymaster coverage

examples/aa_03_batch_operations.zig

  • Batch multiple calls in single UserOp
  • Execute multiple token transfers
  • Approve and swap in one operation
  • Compare gas costs vs individual transactions

examples/aa_04_session_keys.zig

  • Create session key with limited permissions
  • Execute operations with session key
  • Show time/spend limits
  • Revoke session key

examples/aa_05_social_recovery.zig

  • Setup guardians for account
  • Simulate account recovery
  • Replace owner key
  • Guardian management

examples/aa_06_complete_workflow.zig

  • Complete AA workflow:
    • Deploy smart account
    • Setup paymaster
    • Batch operations
    • Monitor events
    • Handle errors

Unit Tests

UserOperation Tests

  • test/user_operation_test.zig:
    • UserOp creation and init
    • ABI encoding/decoding
    • Hash calculation
    • Signature validation

Bundler Client Tests

  • test/bundler_test.zig:
    • RPC method calls
    • Response parsing
    • Error handling
    • Mock bundler responses

Account Tests

  • test/smart_account_test.zig:
    • SimpleAccount deployment
    • Execute operations
    • Signature generation
    • Nonce management

Gas Estimation Tests

  • test/gas_estimation_test.zig:
    • PreVerificationGas calculation
    • Gas limit estimation
    • Paymaster gas overhead
    • Edge cases

Integration Tests

  • test/integration/aa_integration_test.zig:
    • Full UserOp lifecycle
    • Real bundler interaction (testnet)
    • Account deployment
    • Paymaster sponsorship
    • Event monitoring

Documentation

  • Add docs/account_abstraction.md:

    • What is Account Abstraction?
    • Benefits and use cases
    • Quick start guide
    • API reference
    • Best practices
  • Update main README:

    • Add AA features section
    • Link to examples
    • Showcase gasless transactions

Test Network Setup

  • Provide testnet configuration:
    • Sepolia EntryPoint addresses
    • Bundler endpoints
    • Paymaster services
    • Faucet links for testing

Benchmarks

  • Add performance benchmarks:
    • UserOp creation time
    • Gas estimation accuracy
    • Bundler submission latency
    • Compare AA vs EOA transactions

Example Scenarios to Cover

  1. First-time user onboarding (no gas needed)
  2. Mobile wallet (using session keys)
  3. DeFi operations (batch approve + swap)
  4. NFT minting (sponsored by project)
  5. DAO voting (gasless votes)
  6. Subscription payments (automated recurring)
  7. Multi-sig operations (threshold signatures)
  8. Account recovery (social recovery)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions