The MetaTxGateway is the core contract responsible for executing gasless meta-transactions with built-in native token support and automatic refund mechanisms.
This protocol also includes the DI Token, Token Presale, and Token Staking contracts, providing a complete tokenomics suite.
Overview
MetaTxGateway v1.0.0-native-token-support enables secure, gasless meta-transactions with native token (ETH/BNB) support, batch execution, and relayer authorization.
Key Features
🔒 Native Token Validation
Ensures exact native token amounts are provided for meta-transactions that require ETH/BNB transfers.
🔄 Automatic Refunds
Returns unused native tokens to users when transactions fail, preventing fund loss.
📦 Batch Processing
Execute multiple transactions in a single call, reducing gas costs and improving efficiency.
🖋️ EIP-712 Signatures
Cryptographically secure meta-transaction authorization with structured data signing.
🔧 UUPS Upgradeable
Safe upgrade patterns for future enhancements without disrupting existing functionality.
⏸️ Pausable
Owner can pause/unpause contract with a reason.
Contract Interface
Core Functions
executeMetaTransactions
Purpose: Execute a batch of meta-transactions on behalf of a user.
Parameters:
from: The user's address (signature signer)
metaTxs: Array of MetaTransaction structs
signature: EIP-712 signature from the user
nonce: User's current nonce for replay protection
deadline: Transaction expiration timestamp
Returns: Array of boolean values indicating success/failure for each transaction
Key Validations:
Relayer authorization check
Signature verification using EIP-712
Nonce validation for replay protection
Native token amount validation
Deadline enforcement
calculateRequiredValue
Purpose: Calculate the total native token value required for a batch of meta-transactions.
Use Case: Frontend applications can use this to determine how much ETH/BNB to include with the relayer transaction.
setRelayerAuthorization
Purpose: Authorize or deauthorize a relayer address.
pauseWithReason
Purpose: Pause the contract with a reason.
unpause
Purpose: Unpause the contract.
View Functions
getNonce
Purpose: Get the current nonce for a user address.
isRelayerAuthorized
Purpose: Check if a relayer is authorized.
getDomainSeparator
Purpose: Get the EIP-712 domain separator for signature verification.
getMetaTransactionTypehash
Purpose: Get the MetaTransaction struct typehash for EIP-712.
getMainTypehash
Purpose: Get the main typehash for batch meta-transactions.
getSigningDigest
Purpose: Helper for frontend to generate the EIP-712 digest for signing.
getTotalBatchCount
Purpose: Get the total number of batch transactions processed.
getVersion
Returns: "v1.0.0-native-token-support"
Data Structures
MetaTransaction
Events
RelayerAuthorized
Emitted: When relayer authorization status changes.
MetaTransactionExecuted
Emitted: For each individual meta-transaction execution.
NativeTokenUsed
Emitted: When native tokens are used in meta-transactions, showing usage and refund details.
PausedWithReason
Emitted: When the contract is paused with a reason.
The Token Staking contract allows users to lock DI tokens and earn rewards. Staking supports flexible or fixed terms, with rewards distributed in DI tokens.
Key Features
Stake/unstake at any time (or after lock period)
Reward calculation based on staked amount and duration
function buyTokens() external payable;
function claimTokens() external;
function setRate(uint256 newRate) external onlyOwner;
function setSaleActive(bool active) external onlyOwner;
function withdrawFunds(address payable to) external onlyOwner;
function stake(uint256 amount) external;
function unstake(uint256 amount) external;
function claimRewards() external;
function getStaked(address user) external view returns (uint256);
function getPendingRewards(address user) external view returns (uint256);