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

TypeError: tx.chainId/sig.v mismatch on Legacy transaction serialization #3898

Closed
belopash opened this issue Mar 14, 2023 · 3 comments
Closed
Assignees
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6

Comments

@belopash
Copy link

belopash commented Mar 14, 2023

Ethers Version

6.1.0

Search Terms

No response

Describe the Problem

Can't serialize Legacy transaction due to error

TypeError: tx.chainId/sig.v mismatch (argument="sig", value={ "_type": "signature", "networkV": "2606", "r": "0x934e9b41ca05ce6581f4ef6f3f1026b7d190e0e4d0ff63c9b91865beeeb52768", "s": "0x32314ac16b0234e643a46de09e39e62e32568b9dcbbd677fbff1e22ed649fa70", "v": 28 }, code=INVALID_ARGUMENT, version=6.1.0)

Probably happens because of incorrect behavior of this condition

if (tx.chainId != null) {

It checks nullability of tx.chainId, but tx.chainId is never null
get chainId(): bigint { return this.#chainId; }

Code Snippet

const tx = ethers.Transaction.from({
        to: '0x08716e418e68564c96b68192e985762740728018',
        nonce: 603,
        gasLimit: 489365n,
        gasPrice: 1000000000n,
        value: 0n,
        data: '0x7a93696a0000000000000000000000000000000000000000000000000000000000000000',
        type: 0,
        signature: {
            r: '0x934e9b41ca05ce6581f4ef6f3f1026b7d190e0e4d0ff63c9b91865beeeb52768',
            s: '0x32314ac16b0234e643a46de09e39e62e32568b9dcbbd677fbff1e22ed649fa70',
            v: 2606n
        },
    })
    let serialized = tx.serialized

Contract ABI

No response

Errors

TypeError: tx.chainId/sig.v mismatch (argument="sig", value={ "_type": "signature", "networkV": "2606", "r": "0x934e9b41ca05ce6581f4ef6f3f1026b7d190e0e4d0ff63c9b91865beeeb52768", "s": "0x32314ac16b0234e643a46de09e39e62e32568b9dcbbd677fbff1e22ed649fa70", "v": 28 }, code=INVALID_ARGUMENT, version=6.1.0)
  at makeError ([email protected]\node_modules\ethers\lib.commonjs\utils\errors.js:114:21)
  at assert ([email protected]\node_modules\ethers\lib.commonjs\utils\errors.js:138:15)
  at assertArgument ([email protected]\node_modules\ethers\lib.commonjs\utils\errors.js:150:5)
  at _serializeLegacy ([email protected]\node_modules\ethers\lib.commonjs\transaction\transaction.js:109:39)
  at get serialized [as serialized] ([email protected]\node_modules\ethers\lib.commonjs\transaction\transaction.js:494:24)

Environment

node.js (v12 or newer)

Environment (Other)

No response

@belopash belopash added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Mar 14, 2023
@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Mar 14, 2023
@ricmoo
Copy link
Member

ricmoo commented Mar 14, 2023

Thanks! I’ll look into this first thing tomorrow, because it definitely looks like a bug.

@ricmoo ricmoo added bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published. and removed investigate Under investigation and may be a bug. labels Mar 20, 2023
@ricmoo
Copy link
Member

ricmoo commented Mar 20, 2023

This has been fixed in v6.2.0. Try it out and let me know if there are still any issues. :)

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Mar 20, 2023
@belopash
Copy link
Author

Also fixed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants