I'm using the following to send eth to a contract using solidity 0.8.16:
(bool success, bytes memory data) = payable(msg.sender).call{value:someEth}("");
I've tried to get the info from the data
variable, but without success.
Attempt 1:
string memory b = string(data);
This returns an error with the following:
HardhatChaiMatchersDecodingError: There was an error decoding
'0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006408c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0000000000000000000000000000000000000000000000000000000000' as a string
If I decode the section with values, it's trying to describe the nonReentrant error
. If I decode the whole thing, it flags an issue with the continuation byte.
Attempt 2:
(string memory a) = abi.decode(data, (string));
This runs into a runtime error my ide (hardhat) can't parse:
Transaction reverted and Hardhat couldn't infer the reason.
How do I properly decode the data from this return?
payable(msg.sender).call{value:someEth}("");
, what is this supposed to return? Do you know what contract it is calling? To be able to decode the data you will need to know how that data looks, its type, the order in which those types were encoded before returning. If the returned data will change depending on whichmsg.sender
calls, then it will be really hard to decode that data because you wouldn't have information about the data itself.