Skip to content

TronClientSigner.ensure_allowance fails: tronpy build() missing raw_data_hex #64

@Tristenyang

Description

@Tristenyang

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions