Description
TronClientSigner.ensure_allowance() in bankofai/x402/signers/client/tron_signer.py fails when trying to approve token allowance on TRON networks.
Error
bankofai.x402.exceptions.InsufficientAllowanceError: Approval transaction failed: Tron sign_transaction failed: Payload must be an unsigned transaction with {raw_data_hex}. Use TronGrid API to build the transaction first.
Root Cause
In tron_signer.py line 249-251, the approve transaction is built locally via tronpy's AsyncTron:
txn = await txn_builder.build()
txn_dict = txn.to_json()
raw_result = await self._wallet.sign_transaction(txn_dict)
txn.to_json() returns a dict with keys {txID, raw_data, signature, permission} — no raw_data_hex field.
However, bankofai-agent-wallet's TronSigner.sign_transaction() (agent_wallet/core/adapters/tron.py:50) requires raw_data_hex in the payload:
if "raw_data_hex" not in payload:
raise ValueError(
"Payload must be an unsigned transaction with {raw_data_hex}. "
"Use TronGrid API to build the transaction first."
)
This is an interface mismatch between bankofai-x402 (v0.5.8) and bankofai-agent-wallet (v2.4.0).
Expected Behavior
The approve transaction should be built in a format compatible with agent_wallet's sign_transaction, which requires raw_data_hex.
Suggested Fix
Use the TronGrid HTTP API (wallet/triggersmartcontract) to build the transaction instead of tronpy's local build(). The TronGrid API response includes raw_data_hex in the transaction object.
Environment
- bankofai-x402: 0.5.8
- bankofai-agent-wallet: 2.4.0
- Python: 3.12
- Network: tron:nile (testnet)
Description
TronClientSigner.ensure_allowance()inbankofai/x402/signers/client/tron_signer.pyfails when trying to approve token allowance on TRON networks.Error
Root Cause
In
tron_signer.pyline 249-251, the approve transaction is built locally via tronpy'sAsyncTron:txn.to_json()returns a dict with keys{txID, raw_data, signature, permission}— noraw_data_hexfield.However,
bankofai-agent-wallet'sTronSigner.sign_transaction()(agent_wallet/core/adapters/tron.py:50) requiresraw_data_hexin the payload:This is an interface mismatch between
bankofai-x402(v0.5.8) andbankofai-agent-wallet(v2.4.0).Expected Behavior
The approve transaction should be built in a format compatible with
agent_wallet'ssign_transaction, which requiresraw_data_hex.Suggested Fix
Use the TronGrid HTTP API (
wallet/triggersmartcontract) to build the transaction instead of tronpy's localbuild(). The TronGrid API response includesraw_data_hexin the transaction object.Environment