Issue with the solidityPack() from ethers.utils
See original GitHub issueEthers 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:
- Created a year ago
- Comments:11 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the respones. Closing the issue for now.
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! 😃