mcpField
T
TRC20 Token Toolkit

TRC20 Token Toolkit

github.com/bofaiOther163120 installsUpdated 1w ago
Repository

About TRC20 Token Toolkit

A TRC20 operations toolkit for AI agents on TRON, covering balances, transfers, approvals, and token metadata. It accepts common token symbols or contract addresses and includes dry-run and address validation.

Key features

  1. 01Fetch token metadata
  2. 02Check single or batch balances
  3. 03Validate transfers with dry-run
  4. 04Set and check token allowances
  5. 05Use symbols or contract addresses

Use cases

  1. 01Review balances across several tokens
  2. 02Validate an address and amount before sending
  3. 03Set an allowance for a specific contract
  4. 04Look up token name, symbol, and supply

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/bofai/skills --skill trc20-token-toolkit

After installing, type/trc20-token-toolkitin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

.gitignore
README.md
package.json
package-lock.json
resources/
well_known_tokens.json
scripts/
approve.js
balance.js
transfer.js
info.js
utils.js

Details

From the project README

TRC20 Token Toolkit

Universal TRC20 token operations for AI agents on TRON. Check balances, transfer tokens, manage approvals, and fetch metadata for any TRC20 token. Supports symbol-based lookups for common tokens (USDT, USDD, SUN, etc.) and direct contract addresses for any token.


Quick Start

Wallet required: Run agent-wallet list first.
If no wallets exist, invoke bankofai-guide (Section C — Wallet Guard) before proceeding.

  1. Install dependencies:
    cd trc20-toolkit-skill && npm install
    
  2. Set environment variables:
    export TRON_PRIVATE_KEY="<your-private-key>"
    export TRON_NETWORK="mainnet"
    export TRONGRID_API_KEY="<optional>"
    

Caution

Never display or log the private key.


Available Scripts

1. info.js — Token Metadata
node scripts/info.js <tokenAddressOrSymbol>
node scripts/info.js USDT
node scripts/info.js TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t

Output: name, symbol, decimals, total_supply

2. balance.js — Token Balances
# Single token balance
node scripts/balance.js USDT
node scripts/balance.js USDT TWalletAddress123

# Batch balance check
node scripts/balance.js --batch USDT,USDD,SUN
node scripts/balance.js --batch USDT,USDD TWalletAddress123

Output: trx_balance, tokens[] (each with symbol, balance, decimals)

Behavior note: In --batch mode, invalid token inputs are returned as per-item errors instead of aborting the entire batch.

3. transfer.js — Transfer Tokens
ParameterRequiredDescription
tokenYesToken address or symbol
toAddressYesRecipient TRON address
amountYesHuman-readable amount
--dry-runNoValidate only, no transaction
node scripts/transfer.js USDT TRecipientAddress 10.5 --dry-run
node scripts/transfer.js USDT TRecipientAddress 10.5

Output: status, tx_id, amount, symbol

Validation rules: Recipient addresses must be valid TRON addresses, self-transfers are rejected, and amount must be greater than 0 even in --dry-run.

4. approve.js — Manage Allowances
# Set allowance (use the exact amount needed, never unlimited)
node scripts/approve.js USDT TSpenderAddress 1000 --dry-run
node scripts/approve.js USDT TSpenderAddress 1000

# Check current allowance
node scripts/approve.js USDT TSpenderAddress --check
node scripts/approve.js USDT TSpenderAddress --check TWalletAddress

Output: allowance, is_max, status, tx_id

Validation rules: Spender and optional owner addresses must be valid TRON addresses, amount must be greater than 0, and unlimited approvals remain disabled.


Usage Patterns

Pattern 1: Check Before Transfer (Recommended)
node scripts/balance.js USDT
node scripts/transfer.js USDT TRecipient 100 --dry-run
# Confirm with user
node scripts/transfer.js USDT TRecipient 100
Pattern 2: Portfolio Overview
node scripts/balance.js --batch USDT,USDD,SUN,JST,BTT

Security Rules

Caution

  1. Never display private keys in output or logs.
  2. Never transfer without user confirmation. Always use --dry-run first.
  3. Prevent self-transfers. The script rejects transfers to the sender's own address.
  4. Validate addresses. Ensure all addresses start with T and are valid TRON base58 addresses.
  5. Check balances before transfer. The script validates sufficient balance automatically.
  6. Never use unlimited approvals. Always approve only the exact amount needed for the intended swap or transfer. Infinite (MAX_UINT256) approvals are rejected by the script. This prevents a compromised or malicious spender contract from draining the entire token balance.
  7. Treat multi-permission wallets carefully. These scripts assume a directly usable signing key; wallets that require explicit permissionId selection may need a different transaction flow.

Supported Tokens

Common tokens resolved by symbol: USDT, USDD, USDC, WTRX, SUN, JST, BTT, WIN. Any TRC20 token can be used via its contract address.

See resources/well_known_tokens.json for the full list.


Common Issues

ProblemSolution
Unknown token symbolUse the full contract address instead
Insufficient balanceCheck balance first with balance.js
TRON_PRIVATE_KEY requiredSet the environment variable
Cannot find module 'tronweb'Run npm install

Version 1.0.0 — Created by M2M Agent Registry for Bank of AI

Comments

Markdown supported