VaultFactory:
(base58) TUzSRJ2XTBGZbLFsCaDjwVPpbJB7zvNpV6
(hex) 41d0a601aac1033ee872278e64b09ced86fde33682
EntryPoint:
(base58) TNU9zdUJDxb1y1VKHKwYB69X3DzdxRssYW
(hex) 41891b0fd4faabf36e6fd2252560cede6523293b28
This repository implements a smart contract system for relayed TRC20 token transfers via deterministic vaults, deployable using CREATE2
on the TRON blockchain. It includes:
Vault
: Minimal, signature-authorized token vault.VaultFactory
: DeterministicCREATE2
deployer with nonce support.EntryPoint
: Meta-transaction relayer that deploys vaults on demand and forwards signed calls.
- Ownable TRC20 vault.
- Supports gasless
send()
transfers with EIP-191-style signatures. - Nonce-protected to prevent replay attacks.
- Constructor-locked and immutable owner.
- Deploys
Vault
contracts deterministically usingCREATE2
. - Tracks nonces per user to avoid collisions.
- Verifiable vault computation via
computeAddress()
.
- Acts as a trusted relayer.
- Automatically deploys a user’s vault if not yet deployed.
- Emits
MetaTransactionExecuted
after forwarding asend()
.
git clone https://github.com/yourname/vault-relayer-tron.git
cd vault-relayer-tron
npm install
Requires Node.js, TronBox, and
solc
0.8.20 compatible compiler.
Create a .env
file:
PRIVATE_KEY_MAINNET=your_private_key_here
Ensure it's ignored:
echo ".env" >> .gitignore
tronbox compile
tronbox migrate --network development
source .env && tronbox migrate --network mainnet
Ensure .env
has sufficient TRX staked or balance.
Use this script or estimate manually:
- Contract size: ~9 KB
- Estimated Energy: ~1.5–2M
- TRX Cost: ~650–900 TRX without staking
- Tip: Stake TRX for free energy instead of paying per deployment.
- Stake TRX to gain free daily energy and bandwidth.
- Use TronLink or TronGrid’s freeze interface.
- 1000 TRX staked ≈ enough to cover 1–2 deployments/day depending on size.
node scripts/estimate.js
Includes:
- Bytecode-based cost
- TRX calculation
- Account energy status
While TRON doesn't support automatic Etherscan-style verification, you can:
- Flatten contracts manually.
- Upload bytecode and ABI to Tronscan or call
getContract
via API. - For external users, expose your contract source via GitHub or IPFS.
-
User signs a
send(token, to, amount, deadline, nonce)
message. -
EntryPoint.relay()
:- Deploys the vault if not deployed.
- Forwards call to
Vault.send()
.
-
Vault:
- Verifies signature.
- Transfers tokens.
- Increments nonce.
contracts/
├── Vault.sol
├── VaultFactory.sol
└── EntryPoint.sol
migrations/
├── 1_initial_migration.js
└── 2_deploy_contracts.js
scripts/
└── estimate.js
build/ (auto-generated)
- Relayer gas sponsorship rules
- Signature batching
- UI for vault interactions
- GraphQL subgraph integration (TheGraph-style indexing)