question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with the solidityPack() from ethers.utils

See original GitHub issue

Ethers Version

^5.7.1

Search Terms

solidityPack, value out of range, BigNumber

Describe the Problem

I am getting value out of range error when I try to use the solidityPack() method from ethers.utils (refer the code snippet). The language used is JavaScript(React_Native).

Code Snippet

//Note: The address variable here stands for the address of ethereum wallet
const dataGenerated =
            "0x" +
            ethers.utils.hexZeroPad(ethers.BigNumber.from(ethers.utils.parseUnits("0.00000001", 
            18)).toHexString(), 32).substring(2) +
            ethers.utils.hexZeroPad(ethers.utils.hexlify((address.length - 2)/2), 32).substring(2) +
            address.substring(2);

const encodedData = ethers.utils.solidityPack(["uint256"],[dataGenerated]);

Contract ABI

No response

Errors

Error: value out of range (argument="value", value={"type":"BigNumber","hex":"0x..........XX"}, code=INVALID_ARGUMENT, version=bytes/5.7.0)

Environment

node.js (v12 or newer)

Environment (Other)

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
padma1998commented, Nov 10, 2022

Thank you for the respones. Closing the issue for now.

0reactions
ricmoocommented, Nov 10, 2022

Due to spam on this issue, I am locking the conversation. Apologies to anyone who wishes to continue discussion. Please start a Q&A discussion if necessary.

Thanks! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Utilities — ethers.js 4.0.0 documentation
Compute the SHA256 cryptographic hash using the Solidity non-standard (tightly) packed data for values given the types. utils . solidityPack ( types, values...
Read more >
How to mimic abi.encodePacked in ethers?
I found your solution on the ether.js doc. It has some functions that would help : ethers.utils.solidityPack( types,values); ethers.utils.
Read more >
Documentation - Ethers.js
The ethers.js library aims to be a complete and compact library for interacting with the Ethereum Blockchain and its ecosystem. It was originally...
Read more >
Ethers.js: How do I encode an array of addresses into a ...
You can use AbiCoder.encode(types, values). To encode an array of addresses, you could do: const abi = ethers.utils.
Read more >
web3.utils — web3.js 1.0.0 documentation - Read the Docs
Checks if a given string is a HEX string. Difference to web3.utils.isHex() is that it expects HEX to be prefixed with 0x ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found