Skip to content

EVVM-org/scaffold-evvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—οΈ Scaffold-EVVM

A frontend development tool for building EVVM (Ethereum Virtual Machine Virtualization) signature constructors.

Scaffold-EVVM helps you create and execute EIP-191 signed transactions for EVVM operations. This is a pure frontend application - no deployment functionality, just signature construction and transaction execution.


✨ Features

  • βœ… 23+ Signature Constructors - For all EVVM operations (Payments, Staking, NameService, P2PSwap)
  • βœ… Automatic Contract Discovery - Discovers Staking, NameService, and Estimator addresses from EVVM core
  • βœ… Meta-Transaction Pattern - EIP-191 gasless signatures submitted by executors (fishers)
  • βœ… Dual Nonce Support - Sync and async nonce systems for different operation types
  • βœ… Wallet Integration - WalletConnect/Reown support for all major wallets
  • βœ… Built-in Debug Console - View message formats, signatures, and transaction parameters
  • βœ… Block Explorer Integration - Direct links to Etherscan/Arbiscan for transactions

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • A WalletConnect Project ID (Get one free)
  • An existing EVVM contract address (deployed on testnet)

Installation

# Clone the repository
git clone <your-repo-url>
cd scaffold-evvm

# Install dependencies
npm install

Configuration

  1. Copy environment template:

    cp .env.example .env
  2. Configure .env:

    # Required: WalletConnect Project ID
    NEXT_PUBLIC_PROJECT_ID=your_reown_project_id_here
    
    # Required: Your EVVM contract address
    NEXT_PUBLIC_EVVM_ADDRESS=0x...your_evvm_contract_address
    
    # Required: Network chain ID
    # 11155111 = Ethereum Sepolia
    # 421614   = Arbitrum Sepolia
    NEXT_PUBLIC_CHAIN_ID=11155111
    
    # Optional: EVVM instance ID (if registered)
    NEXT_PUBLIC_EVVM_ID=
  3. Start development server:

    npm run dev
  4. Open your browser:

    http://localhost:3000
    

🎯 What This Tool Does

Contract Discovery Flow

User provides EVVM address (.env)
          ↓
App reads EVVM contract on-chain
          ↓
Discovers contract addresses automatically:
  β€’ Staking:     evvm.getStakingAddress()
  β€’ NameService: evvm.getNameServiceAddress()
  β€’ Estimator:   evvm.getEstimatorAddress()
          ↓
Ready to build signatures!

Signature Constructor Flow

1. User fills form β†’ Component collects parameters
2. Click "Sign" β†’ Creates EIP-191 message
3. Wallet prompts β†’ User signs message off-chain
4. Click "Execute" β†’ Submits to EVVM contract
5. Transaction confirmed β†’ View on block explorer

πŸ“š Available Signature Constructors

Payment Operations (EVVM)

  • signPay - Single payment to address or username
  • signDispersePay - Multiple payments in one transaction
  • signPayMultiple - Batch payments (advanced)

Staking Operations

  • signGoldenStaking - Become a golden fisher (special privileges)
  • signPresaleStaking - Presale staking (1 MATE fixed)
  • signPublicStaking - Public staking (5083 MATE per sMATE)
  • signPublicServiceStaking - Staking for ecosystem services

NameService Operations

  • signPreRegistrationUsername - Reserve a username
  • signRegistrationUsername - Register a username
  • signMakeOffer - Make an offer for a username
  • signWithdrawOffer - Withdraw your username offer
  • signAcceptOffer - Accept an offer for your username
  • signRenewUsername - Renew your username registration
  • signAddCustomMetadata - Add custom metadata to username
  • signRemoveCustomMetadata - Remove custom metadata
  • signFlushCustomMetadata - Remove all custom metadata
  • signFlushUsername - Delete username completely

P2P Swap Operations

  • signMakeOrder - Create a P2P swap order
  • signCancelOrder - Cancel your swap order
  • signDispatchOrderFillProportionalFee - Fill order with proportional fee
  • signDispatchOrderFillFixedFee - Fill order with fixed fee

πŸ—οΈ Project Structure

scaffold-evvm/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                          # Next.js 15 pages
β”‚   β”‚   β”œβ”€β”€ page.tsx                  # Homepage with all constructors
β”‚   β”‚   β”œβ”€β”€ evvm/                     # EVVM-specific pages
β”‚   β”‚   └── faucet/                   # Testnet faucet
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   └── SigConstructors/          # 23 signature constructor components
β”‚   β”‚       β”œβ”€β”€ Evvm/                 # Payment constructors
β”‚   β”‚       β”œβ”€β”€ StakingFunctions/     # Staking constructors
β”‚   β”‚       β”œβ”€β”€ NameService/          # NameService constructors
β”‚   β”‚       └── P2PSwap/              # P2PSwap constructors
β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ useEvvmDeployment.ts      # Contract discovery hook
β”‚   β”‚   └── ...other hooks
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ evvmSignatures.ts         # Centralized signature builders
β”‚   β”‚   β”œβ”€β”€ evvmConfig.ts             # EVVM configuration utilities
β”‚   β”‚   └── viemClients.ts            # Viem client setup
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── transactionExecuters/     # Transaction execution functions
β”‚   β”‚       β”œβ”€β”€ evvmExecuter.ts       # Payment executors
β”‚   β”‚       β”œβ”€β”€ stakingExecuter.ts    # Staking executors
β”‚   β”‚       β”œβ”€β”€ nameServiceExecuter.ts # NameService executors
β”‚   β”‚       └── p2pSwapExecuter.ts    # P2PSwap executors
β”‚   └── types/
β”‚       └── evvm.ts                   # TypeScript type definitions
β”œβ”€β”€ .env                              # Your configuration (not committed)
β”œβ”€β”€ .env.example                      # Configuration template
└── package.json

πŸ”§ Development Commands

# Start development server (with env validation)
npm run dev

# Build for production
npm run build

# Start production server
npm run start

# Type checking
npm run type-check

# Validate environment configuration
npm run check-env

πŸŽ“ How EVVM Works

Meta-Transaction Pattern

EVVM uses EIP-191 signed messages instead of traditional contract calls:

  1. User signs message off-chain (no gas cost)
  2. Executor (fisher) submits on-chain (pays gas)
  3. Contract verifies signature and executes
  4. User receives result without paying gas

Message Format:

selector,evvmID,from,to,token,amount,priorityFee,nonce,priorityFlag,executor

Example:

0x4faa1fa2,1057,0xAlice,0xBob,0x001,1000000,0,42,false,0x0

Dual Nonce System

  • Sync Nonces (priorityFlag: false) - Sequential, for operations requiring order
  • Async Nonces (priorityFlag: true) - Parallel, for independent operations

Dual Signature Operations

Some operations require two signatures:

  1. EVVM signature - For payment/transfer
  2. Module signature - For specific module action

Examples: Staking, NameService, P2PSwap operations


🌐 Supported Networks

  • Ethereum Sepolia (Chain ID: 11155111)
  • Arbitrum Sepolia (Chain ID: 421614)
  • Local Anvil (Chain ID: 31337)
  • Any EVM-compatible testnet

πŸ› Troubleshooting

"No EVVM address found"

  • Check .env has NEXT_PUBLIC_EVVM_ADDRESS set
  • Run npm run check-env to validate configuration
  • Ensure address format is valid (0x...)

"Contract discovery failed"

  • Verify EVVM contract is deployed at the address
  • Check network connection (RPC endpoint working)
  • Ensure NEXT_PUBLIC_CHAIN_ID matches the actual network
  • Check browser console for detailed error messages

"Nonce too low" or "Nonce already used"

  • Always fetch current nonce from contract before signing
  • Use getCurrentSyncNonce for sync operations
  • Use getNextRandomNonce for async operations
  • Don't reuse old signatures

"Signature verification failed"

  • Verify EVVM ID matches the deployed instance
  • Check all parameters match between signing and execution
  • Ensure priorityFlag matches nonce type
  • Confirm wallet is connected to correct network

Golden Staking Issues

  • Must use sync nonce (priorityFlag: false)
  • Requires 24-hour cooldown between stakes
  • See critical fix in evvmSignatures.ts:189-240

πŸ“¦ Dependencies

  • Next.js 15 - React framework with App Router
  • viem - Ethereum library for contract interactions
  • wagmi - React hooks for Ethereum
  • @reown/appkit - Wallet connection (WalletConnect)
  • @evvm/viem-signature-library - Official EVVM signature builders

πŸ” Security

  • βœ… Never commit .env file (in .gitignore)
  • βœ… All signing happens client-side in browser
  • βœ… No private keys stored or transmitted
  • βœ… WalletConnect for secure wallet connections
  • ⚠️ Testnet only - Not audited for mainnet

πŸ“– Documentation


🀝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

πŸ“œ License

MIT License - see LICENSE file for details


πŸ™ Acknowledgments


πŸ“ž Support


Made with ❀️ for the EVVM ecosystem

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published