Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error invalid hexlify value with transaction type 0 #4566

Open
sangnguyen1001 opened this issue Jan 31, 2024 · 1 comment
Open

Error invalid hexlify value with transaction type 0 #4566

sangnguyen1001 opened this issue Jan 31, 2024 · 1 comment
Assignees
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5

Comments

@sangnguyen1001
Copy link

sangnguyen1001 commented Jan 31, 2024

Ethers Version

5.7.2

Search Terms

No response

Describe the Problem

I have a transaction object was populated with type 0:

tx = {"to"=>"0x3f1B32386dE69693F708204BEC1568aB6599E0e6",
 "value"=>"0x16345785d8a0000",
 "data"=>"0x",
 "type"=>0,
 "nonce"=>0,
 "gasLimit"=>{"type"=>"BigNumber", "hex"=>"0x5208"},
 "gasPrice"=>{"type"=>"BigNumber", "hex"=>"0x59682f10"},
 "from"=>"0xc9aAD004e656153e7Ea4633BbF3Dc10BcE7a50fb",
 "chainId"=>80001}

When I sign it (offline) with code below:

      const signer = new ethers.Wallet(privateKey);
      const txRaw = await signer.signTransaction(tx);

Then I get error:
{"reason"=>"invalid hexlify value", "code"=>"INVALID_ARGUMENT", "argument"=>"value", "value"=>{"type"=>"BigNumber", "hex"=>"0x59682f10"}}

If I populate transaction using type 2:

{"to"=>"0x3f1B32386dE69693F708204BEC1568aB6599E0e6",
 "value"=>"0x16345785d8a0000",
 "data"=>"0x",
 "type"=>2,
 "nonce"=>0,
 "gasLimit"=>{"type"=>"BigNumber", "hex"=>"0x5208"},
 "gasPrice"=>nil,
 "from"=>"0xc9aAD004e656153e7Ea4633BbF3Dc10BcE7a50fb",
 "maxFeePerGas"=>{"type"=>"BigNumber", "hex"=>"0x59682f20"},
 "maxPriorityFeePerGas"=>{"type"=>"BigNumber", "hex"=>"0x59682f00"},
 "chainId"=>80001}

Then it will be signed ok

Plz help, thanks!

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

node.js (v12 or newer)

Environment (Other)

No response

@sangnguyen1001 sangnguyen1001 added investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5 labels Jan 31, 2024
@sangnguyen1001
Copy link
Author

I found it,
If I change tx from

tx = {"to"=>"0x3f1B32386dE69693F708204BEC1568aB6599E0e6",
 "value"=>"0x16345785d8a0000",
 "data"=>"0x",
 "type"=>0,
 "nonce"=>0,
 "gasLimit"=>{"type"=>"BigNumber", "hex"=>"0x5208"},
 "gasPrice"=>{"type"=>"BigNumber", "hex"=>"0x59682f10"},
 "from"=>"0xc9aAD004e656153e7Ea4633BbF3Dc10BcE7a50fb",
 "chainId"=>80001}

to

tx = {"to"=>"0x3f1B32386dE69693F708204BEC1568aB6599E0e6",
 "value"=>"0x16345785d8a0000",
 "data"=>"0x",
 "type"=>0,
 "nonce"=>0,
 "gasLimit"=>"0x5208",
 "gasPrice"=>"0x59682f10",
 "from"=>"0xc9aAD004e656153e7Ea4633BbF3Dc10BcE7a50fb",
 "chainId"=>80001}

it will work.

Note that I populate the tx with:

    const provider = new ethers.providers.JsonRpcProvider(nodeUrl);
    const signer = provider.getSigner(fromAddress);

    try {
      const tx = await signer.populateTransaction({
        to: toAddress,
        value: amount,
        data: "0x",
        type: 0
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5
Projects
None yet
Development

No branches or pull requests

2 participants