Overview
TRC21 is Viction’s innovative token standard that enables gasless transactions. Users can pay transaction fees using the tokens themselves instead of holding VIC for gas, making blockchain interactions seamless and user-friendly.Key Innovation
Traditional blockchain transactions require users to hold native tokens (ETH, VIC, etc.) for gas fees. TRC21 solves this by:- Fee Abstraction: Transaction fees paid in the token being transferred
- Better UX: Users only need one token, not native + token
- Issuer Control: Token issuers can subsidize or profit from fees
- ERC20 Compatible: Extends ERC20 with fee functionality
Token Interface
The TRC21 interface extends standard ERC20:contracts/tomox/contract/TRC21.sol:8
Fee Mechanism
How Fees Work
When a user transfers TRC21 tokens:- Fee Calculation: System calls
estimateFee()to determine fee - Total Deduction: User’s balance reduced by
amount + fee - Transfer:
amounttokens sent to recipient - Fee Payment:
feetokens sent to issuer - Fee Event:
Feeevent emitted for tracking
contracts/tomox/contract/TRC21.sol:127
Fee Estimation
Users can check fees before transacting:contracts/tomox/contract/TRC21.sol:103
The standard implementation uses a flat fee (_minFee), but issuers can implement:
- Percentage-based fees
- Tiered fee structures
- Dynamic fees based on network conditions
- Zero fees (fully subsidized)
Token Issuer
Every TRC21 token has an issuer who:- Receives Fees: Collects transaction fees
- Sets Fee Amount: Controls
_minFeevalue - Maintains Capacity: Deposits VIC for gas subsidy
- Manages Token: Controls token parameters
contracts/tomox/contract/TRC21.sol:86
TRC21 Issuer Contract
To enable TRC21 functionality, token issuers must register:contracts/trc21issuer/contract/TRC21Issuer.sol:7
Applying for TRC21
Token issuers must deposit VIC to cover gas costs:contracts/trc21issuer/contract/TRC21Issuer.sol:38
Adding Capacity
Issuers can add more VIC to maintain gas subsidy:contracts/trc21issuer/contract/TRC21Issuer.sol:46
Checking Capacity
contracts/trc21issuer/contract/TRC21Issuer.sol:28
Implementation Example
Full TRC21 token with multisig and burn functionality:contracts/tomox/contract/TRC21.sol:345
Transfer Variants
Standard Transfer
contracts/tomox/contract/TRC21.sol:127
Transfer From (Allowance)
contracts/tomox/contract/TRC21.sol:163
Approve
Approval also requires fee payment:contracts/tomox/contract/TRC21.sol:148
Token Burning
TRC21 tokens can implement burning with fees:contracts/tomox/contract/TRC21.sol:483
Burning enables:
- Wrapped Tokens: Burn to redeem on another chain
- Deflationary Models: Reduce supply over time
- Exit Mechanisms: Convert to other assets
Minting (Multisig)
The example implementation includes multisig minting:contracts/tomox/contract/TRC21.sol:502
Gas Subsidy Mechanism
How TRC21 transactions work under the hood:- User Submits Transaction: Signs transaction with 0 gas price
- Validator Checks Issuer: Verifies token has capacity in TRC21Issuer
- Validator Pays Gas: Pays VIC gas cost from validator balance
- Fee Collection: Token fee transferred to issuer
- Issuer Reimbursement: Validator collects gas cost from issuer’s deposit
- Users only interact with one token
- Validators are always reimbursed
- Issuers control the economics
Use Cases
Stablecoins
Users can transact without holding volatile VIC:- Send USDT without needing VIC
- Fees paid in USDT itself
- Simplified onboarding
Loyalty Programs
Brands can issue tokens with:- Zero fees (fully subsidized)
- Users never need blockchain knowledge
- Seamless reward redemption
Payment Tokens
Merchants accept tokens for payment:- Customers pay only in the payment token
- Transaction fees covered by merchant
- No blockchain complexity for customers
Gaming Assets
In-game currencies and items:- Players trade without managing gas
- Game developer subsidizes fees
- Standard gaming UX
Best Practices
For Token Issuers
- Maintain Capacity: Monitor and refill TRC21Issuer deposit
- Set Reasonable Fees: Balance revenue with user experience
- Communicate Fees: Display fees clearly in UI
- Monitor Usage: Track gas consumption and fee revenue
For Developers
- Check Capacity: Verify issuer has sufficient VIC deposit
- Estimate Fees: Call
estimateFee()before transactions - Handle Fee Events: Listen to
Feeevents for accounting - Test Thoroughly: Edge cases with zero balances and fees
For Users
- Understand Fees: Check fee amount before transacting
- Maintain Balance: Ensure balance covers amount + fee
- Verify Issuer: Check token is properly registered
- Compare Costs: Compare TRC21 fees to gas costs
Token Lifecycle
1. Deploy Token Contract
2. Register with TRC21Issuer
3. Users Transact
4. Maintain Capacity
What happens if the issuer's capacity runs out?
What happens if the issuer's capacity runs out?
If the issuer’s VIC deposit is depleted:
- TRC21 transactions will fail
- Users must either wait for issuer to refill or
- Use standard VIC for gas (fallback to normal ERC20 behavior)
- Validators won’t process TRC21 transactions without capacity
Can TRC21 tokens be used in smart contracts?
Can TRC21 tokens be used in smart contracts?
Yes, TRC21 tokens work in smart contracts with considerations:
- Contract must account for fees in logic
- Check
total = amount + estimateFee(amount) - Contract needs sufficient token balance for fees
- Fee goes to issuer, not the contract
- Use standard ERC20 interface for compatibility
Are TRC21 tokens compatible with ERC20 wallets?
Are TRC21 tokens compatible with ERC20 wallets?
Yes, TRC21 extends ERC20:
- All ERC20 functions are supported
- Wallets see them as standard tokens
- Fee handling is transparent to wallets
- Some wallets may not show fee separately
- Total deduction (amount + fee) is visible in transaction history
How do fees compare to gas costs?
How do fees compare to gas costs?
Fee economics depend on the issuer’s model:
- Subsidized: Fees < gas costs (issuer loses money but gains users)
- Break-even: Fees ≈ gas costs (issuer covers expenses)
- Profitable: Fees > gas costs (issuer generates revenue)
See Also
- Smart Contracts - Deploy and interact with TRC21 tokens
- TomoX DEX - Trade TRC21 tokens
- TomoX Lending - Use TRC21 tokens as collateral