Replies: 1 comment
-
It's worse than just an additional I think there is another problem with the code though. I don't believe the solc Everything seems weird about those weird bytes though. It seems like maybe the selector is wrong? Or that something is being truncated somewhere? My first thoughts though, are this isn't a bug in ethers, so I'll move it to discussions for now. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Ethers Version
5.7.2
Search Terms
bytes to string, encodeFunctionData, interface, arrayify
Describe the Problem
Hello, I have a contract where I need to pass an encoded call data to a contract as a string (instead of bytes) - no other choice :/
I am using
encodeFunctionData
to encode the function call, then usingarrayify
to parse the string as bytes, thenBuffer.from(bytes).toString()
to parse the bytes as string and pass it to the solidity contract where I can just do anaddress.call(bytes(myStringBytes))
.However when I receive the string on the contract, there is a difference in the bytes which cause the
.call
to fail. I supposed it is related to the wayBuffer.from
convert the uint8 array to string. I have tried multiple encoding and other methods with no luck so far.Any idea what will be the proper way to convert an (arrayified) array of bytes to string so it can be passed as a string argument to a solidity function?
Many thanks !
Code Snippet
Contract ABI
Errors
Not an error but the log where you can see the difference in both (additional
efbfbd
bytes)Environment
Hardhat
Environment (Other)
No response
Beta Was this translation helpful? Give feedback.
All reactions