Skip to content

_prepare_transaction sends chainId as an int to eth_estimateGas; Bradbury rejects every deploy and write #142

Backlog

Description

@jmiro1

Version: genlayer-py 0.19.1 (tag v0.19.1). The same line is on main: genlayer_py/contracts/actions.py, "chainId": self.chain.id.
Network: testnet_bradbury (chain 4221).

What happens

Every deploy_contract and write_contract on Bradbury fails before anything is sent:

GenLayerError: Transaction failed: eth_estimateGas failed (code=-32602): invalid argument 0: json: cannot unmarshal non-string into Go struct field TransactionArgs.chainId of type *hexutil.Big

_prepare_transaction builds the transaction with "chainId": self.chain.id (an int) and passes it straight to eth_estimateGas. Bradbury's node only accepts a hex quantity there. Studio accepts the int, so this does not show up on Studionet.

Repro

from genlayer_py import create_client, create_account
from genlayer_py.chains import testnet_bradbury

client = create_client(chain=testnet_bradbury, account=create_account(PRIVATE_KEY))  # any funded account
est = client.estimate_transaction_fees({})
client.deploy_contract(
    code=open("contract.py").read(),
    args=[],
    fees={"distribution": est["distribution"], "feeValue": est["feeValue"]},
)
# -> eth_estimateGas failed (code=-32602) ... TransactionArgs.chainId of type *hexutil.Big

Suggested fix

Send it as a hex quantity, like nonce, value and the fee caps in the same dict:

"chainId": hex(self.chain.id),

With only that change, deploys, writes and a full contract call with LLM consensus work on Bradbury. Each ends ACCEPTED / FINISHED_WITH_RETURN, and the call finalizes about 30 minutes later. sign_transaction accepts either form, so signing is unaffected.

Workaround we use until a release includes the fix (wraps provider.make_request): https://github.com/Alpaca-Network/gatewayz-genlayer/blob/main/gzgl/net.py, _hex_chain_id_in_gas_estimates.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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