@t402/evm-core
v2.7.1
Published
T402 Payment Protocol EVM Core Types - Zero external dependencies
Downloads
850
Maintainers
Readme
@t402/evm-core
T402 EVM Core Types and Utilities - Zero external dependencies.
Overview
This package provides EVM types, constants, and utilities for the T402 payment protocol without requiring viem as a dependency. Use this package when you want to work with T402 EVM types without bundling the full viem library.
For full EVM functionality with viem integration, use @t402/evm instead.
Installation
npm install @t402/evm-core
# or
pnpm add @t402/evm-coreUsage
import {
// Primitive types
type Address,
type Hex,
bytesToHex,
hexToBytes,
// Payment types
type ExactEIP3009Payload,
type UptoEIP2612Payload,
// Constants
authorizationTypes,
eip3009ABI,
// Signer interfaces
type ClientEvmSigner,
type FacilitatorEvmSigner,
// Token registry
TOKEN_REGISTRY,
getTokenConfig,
getNetworkTokens,
// Utilities
createNonce,
getEvmChainId,
} from "@t402/evm-core";
// Use types without viem
const payload: ExactEIP3009Payload = {
authorization: {
from: "0x...",
to: "0x...",
value: "1000000",
validAfter: "0",
validBefore: "1893456000",
nonce: createNonce(),
},
};When to Use This Package
Use @t402/evm-core when:
- You only need types and don't need viem functionality
- You're building a type-only package that depends on T402 types
- You want to reduce bundle size by avoiding viem
- You're using a different EVM library (ethers.js, web3.js, etc.)
Use @t402/evm when:
- You need full EVM signing and verification
- You're using viem in your project
- You need the client or facilitator scheme implementations
Exports
Primitive Types
Address- Ethereum address type (`0x${string}`)Hex- Hexadecimal string typeBytes32- 32-byte hex valuebytesToHex()- Convert Uint8Array to hexhexToBytes()- Convert hex to Uint8Array
Payment Types
ExactEIP3009Payload- EIP-3009 TransferWithAuthorization payloadExactLegacyPayload- Legacy approve+transferFrom payloadUptoEIP2612Payload- EIP-2612 Permit payload for metered paymentsPermitSignature- EIP-2612 signature componentsPermitAuthorization- EIP-2612 permit parameters
Constants
authorizationTypes- EIP-712 type definitions for EIP-3009legacyAuthorizationTypes- EIP-712 type definitions for legacy floweip3009ABI- ABI for EIP-3009 token contractserc20LegacyABI- ABI for standard ERC-20 operations
Signer Interfaces
ClientEvmSigner- Interface for client-side signingFacilitatorEvmSigner- Interface for facilitator operationstoClientEvmSigner()- Convert to ClientEvmSignertoFacilitatorEvmSigner()- Convert to FacilitatorEvmSigner
Token Registry
TOKEN_REGISTRY- Complete token configuration by networkUSDT0_ADDRESSES- USDT0 contract addressesUSDC_ADDRESSES- USDC contract addressesgetTokenConfig()- Get token config by network/symbolgetNetworkTokens()- Get all tokens for a networkgetTokenByAddress()- Find token by contract addressgetEIP712Domain()- Get EIP-712 domain for token
Utilities
createNonce()- Generate random 32-byte noncegetEvmChainId()- Get chain ID from network name
Related Packages
@t402/core- Core protocol types and client@t402/evm- Full EVM mechanism with viem integration@t402/fetch- HTTP wrapper with automatic payment handling
License
Apache-2.0
