Permit402 smart contract for the x402 payment protocol — gasless ERC20 payment authorization on EVM and TRON
x402-contracts is an early-stage Solidity project in the AI payments / x402 ecosystem, focused on bsc, defi, eip712, evm. It currently has 3 GitHub stars and 0 forks, and sits alongside related tools like x402-sdk-ts, x402-sdk-go, chaingpt-claude-skill.
Smart contracts for the x402 payment protocol on TRON and EVM chains. Enables gasless, signature-based (EIP-712) payment authorizations and native token settlement.
x402 is an open, neutral standard for internet-native payments. It brings to life the HTTP 402 Payment Required status code so that servers can request payment from clients in a programmatic way—ideal for API paywalls, agent-to-agent payments, and micropayments.
permitTransferFrom with the signature.approve of the Permit402 contract.feeTo and feeAmount for protocol or facilitator fees.validAfter / validBefore.| Component | Role | File(s) |
|---|---|---|
| Permit402 (EVM) | Entry point for EVM chains (Ethereum, BSC, etc.) | contracts/evm/Permit402.sol |
| Permit402 (TRON) | Entry point for TRON (USDT-compatible) | contracts/tron/Permit402.sol |
| Permit402Base | Shared logic, EIP-712, nonce | contracts/core/Permit402Base.sol |
| PermitHash | EIP-712 struct hashes | contracts/libraries/PermitHash.sol |
| EIP712 | Domain separator and typed data hashing | contracts/core/EIP712.sol |
| IPermit402 | Structs and interface for permits | contracts/interface/IPermit402.sol |
Flow: User signs Permit402Details (payment, fee, validity, nonce) → Relayer/backend calls permitTransferFrom(permit, owner, signature) → Contract pulls tokens from owner to payTo (and optional feeTo) in one shot.
| Network | Chain / Environment | Permit402 Address |
|---|---|---|
| TRON Mainnet | Mainnet | TT8rEWbCoNX7vpEUauxb7rWJsTgs8vDLAn |
| TRON Nile | Testnet | TFxDcGvS7zfQrS1YzcCMp673ta2NHHzsiH |
| TRON Shasta | Testnet | TR2XninQ3jsvRRLGTifFyUHTBysffooUjt |
| Network | Chain / Environment | Permit402 Address |
|---|---|---|
| BSC Mainnet | Mainnet | 0x105a6f4613a1d1c17ef35d4d5f053fa2e659a958 |
| BSC Testnet | Testnet | — |
npx hardhat deploy --network <network>npx hardhat deploy --network <network># Compile (Hardhat, with tronSolc for TRON targets)
npx hardhat compile
# Test with Foundry
forge test -vvv
# Test with Hardhat
npx hardhat test
├── contracts/
│ ├── core/
│ │ ├── Permit402Base.sol # Shared permit logic (abstract)
│ │ └── EIP712.sol # EIP-712 domain and hashing
│ ├── evm/
│ │ └── Permit402.sol # EVM implementation (Ethereum, BSC, etc.)
│ ├── tron/
│ │ └── Permit402.sol # TRON implementation (USDT-compatible)
│ ├── interface/
│ │ ├── IPermit402.sol # Permit structs and interface
│ │ ├── IEIP712.sol
│ │ └── IERC1271.sol
│ └── libraries/
│ ├── PermitHash.sol # TypeHashes and struct hashes
│ └── SafeTransferLib.sol # EVM safe transfer (returns bool)
├── deploy/ # EVM deploy scripts (hardhat-deploy)
├── deployTron/ # TRON deploy scripts (sunhat)
├── test/
├── hardhat.config.ts # Hardhat + sunhat + hardhat-foundry config
├── foundry.toml # Foundry config (tests & remappings)
└── AGENTS.md # Guidelines for AI/agent use of this repo
"Permit402" and the struct definitions from IPermit402.sol and PermitHash.sol so that hashes match the contract. Domain separator uses block.chainid and contract address (see contracts/core/EIP712.sol).Permit402Details (meta, buyer, caller, payment, fee, delivery), hash with PermitHash and domain separator, then sign (e.g. 65-byte r || s || v).permitTransferFrom(permit, transferDetails, owner, signature). The owner must have approved the Permit402 contract for the payToken (and have sufficient balance for amount plus optional feeAmount).For full struct and field definitions, see contracts/interface/IPermit402.sol.
validAfter/validBefore limit replay across chains and time.We welcome responsible disclosure. Please report issues privately before public disclosure when possible.
MIT. See LICENSE for full text.
main.Permit402Base.sol and PermitHash.sol).For agent/AI usage of this codebase, see AGENTS.md.
TypeScript SDK for the x402 payment protocol — client signing, server paywall, and facilitator integration for EVM and TRON
Go SDK for the x402 payment protocol — client signing, server paywall middleware, and facilitator
154 Web3 MCP tools for Claude Code, custody-free. Plus an agent wallet prompt injection can't drain: per-tx, daily, and on-chain (ERC-4337) spending caps the model can't bypass. EVM + Solana + Tron DEX/DeFi, perps, prediction markets, contract deploy + audit.
Your AI trading terminal assistant for US stocks, commodities, forex, and crypto.
The living ecosystem where AI agents complete tasks through workflow loops, improve through iterative execution, are evaluated by mentor agents or humans in the loop, and turn completed work into reusable work experience and data to improve future agents.
The trust layer for agent-to-agent commerce — natural-language mandates, ERC-7710 delegated permissions, x402 payments, escrow, and dispute resolution as one open, catch-all Agent Skill / Claude Code plugin.
Open Source AI trading agent that operates autonomously across 1000+ markets - Polymarket, Kalshi, Binance, Hyperliquid, Solana DEXs, 5 EVM chains. Scans for edge, executes instantly, manages risk while you sleep. Agent commerce protocol for machine-to-machine payments. Self-hosted. Built on Claude.
Context-aware agentic LLM gateway & router that optimize your agentic workflows with every runs, works with any harnesses, any models, any workflows.
Multi-Agent AI Task Orchestrator 2026