Smart Contracts
HashNut's payment infrastructure is built on audited smart contracts that ensure secure, transparent, and non-custodial fund management.
Contract Architecture
Core Contracts
PaymentSplitter Contract
The main contract that manages all payment operations:
Key Functions:
batchCreateReceiptWallets(count): Create address poolclaimReceiptERC20Tokens(...): Aggregate fundsreleaseERC20Tokens(...): Withdraw fundssetWithdrawalAddress(...): Configure withdrawal
Contract Types
EVM Chains (Ethereum, Polygon, BSC, etc.)
Contract: PaymentSplitterLogic
Standards:
- ERC-20 compatible
- EIP-712 signature support
- EIP-1559 gas optimization
TRON Network
Contract: PaymentSplitterLogicTron
Standards:
- TRC-20 compatible
- TRON-specific optimizations
Contract Deployment
Deployment Process
Factory Pattern
HashNut uses a Singleton Factory pattern for gas optimization:
Benefits:
- ✅ Gas Savings: Shared factory reduces deployment costs
- ✅ Deterministic Addresses: Predictable contract addresses
- ✅ Upgradeability: Factory can deploy updated versions
- ✅ Security: Centralized factory management
Address Pool System
Receipt Wallet Creation
Address Assignment
Features:
- Automatic Assignment: System assigns addresses automatically
- Pool Management: Tracks used/available addresses
- Deterministic: Addresses can be regenerated if needed
- Batch Creation: Create multiple addresses in one transaction
Fund Management
Payment Receipt
Fund Aggregation
Features:
- Batch Processing: Up to 50 wallets per transaction
- Selective Aggregation: Only process wallets with sufficient balance
- Multi-Token: Aggregate multiple token types in one transaction
- Gas Optimization: Minimum amount thresholds reduce gas costs
Fund Withdrawal
Features:
- Multi-Token Withdrawal: Withdraw multiple tokens in one transaction
- Fee Calculation: Transparent platform fee calculation
- Withdrawal Address: Funds sent to pre-configured address
- On-Chain Verification: All withdrawals verified on blockchain
Contract Security
Security Features
Security Measures:
- ✅ Access Control: Only contract owner can execute critical functions
- ✅ Audited Code: Regular third-party security audits
- ✅ Open Source: Contract code verifiable on-chain
- ✅ Immutable Core: Critical payment logic cannot be changed
- ✅ Multi-Sig Support: Optional multi-signature wallets
Audit Reports
HashNut contracts undergo regular security audits:
- Third-party security firms
- Public audit reports
- Continuous monitoring
- Bug bounty programs
Contract Addresses
Testnet Addresses
Ethereum Sepolia:
- Factory:
0x... - PaymentSplitter:
0x...
Polygon Mumbai:
- Factory:
0x... - PaymentSplitter:
0x...
TRON Shasta:
- Factory:
T... - PaymentSplitter:
T...
Mainnet Addresses
Coming Soon: Mainnet contract addresses will be published here.
Contract Interaction
Reading Contract State
// Example: Check receipt wallet balance
const balance = await contract.getReceiptWalletBalance(
receiptAddress,
tokenAddress
);
Writing to Contract
// Example: Aggregate funds
const tx = await contract.claimReceiptERC20Tokens(
tokenAddresses,
minAmounts,
startIndex,
endIndex
);
await tx.wait(); // Wait for confirmation
Gas Optimization
Batch Operations
Optimization Strategies:
- Batch Creation: Create 50 addresses in one transaction
- Batch Aggregation: Process up to 50 wallets per transaction
- Selective Processing: Only process wallets with sufficient balance
- Gas Estimation: Pre-calculate gas costs before execution
Contract Upgrades
Upgradeability
HashNut contracts use:
- Proxy Pattern: For upgradeable contracts
- Factory Updates: Factory can deploy new contract versions
- Backward Compatibility: Maintains compatibility with existing integrations
Next Steps
- Learn about Payment Flow with smart contracts
- Understand Fund Management operations
- Explore Account Creation process
Ready to deploy? Check out Account Creation →