3

I’m aware that, in Remix, I could input msg.data as calldata values and send that as a transaction. It works for me when I send encoded function calls with parameters.

However, how do I encode and send calldata of functions without any parameters or view/pure functions and see the returned values in the console?

For example, in my case, I have a Proxy contract which points to an implementation contract. I'm using the UUPS proxy setup provided by OpenZeppelin. The implementation contract has a view or pure function that looks like this:

function owner() public view returns (address) { ... }

How should I encode this and pass it into the calldata input in Remix and see the returned value in its console?

enter image description here

PS: The contract I'm interacting with is a proxy and so it has the fallback function. The owner() function in the example is in the implementation contract which the proxy is pointed to.

5
  • Please, can you add an example? Apr 4, 2022 at 13:24
  • @Kerry99 I have added an example and a screenshot of the calldata input in Remix that I'm referring to. Let me know if this helps to clarify the question. Thanks!
    – xenon
    Apr 4, 2022 at 13:29
  • Okay, can you include all your smart contracts code? Apr 4, 2022 at 14:27
  • @Kerry99 I don't really have much of my own code yet. Everything I'm using is what OpenZepplin provided in its UUPS setup. The key thing is I don't know how to encode view/pure functions that return values into the calldata input in Remix and see the returned value in the Remix console.
    – xenon
    Apr 4, 2022 at 15:33
  • I compile the target contract (or the interface), then use the "At address" option to instantiate the target contract at the proxy address.
    – Ismael
    Apr 6, 2022 at 5:25

1 Answer 1

1

I had the exact same question when learning proxies. There are a few ways to do it. You could use ethers.js encodeFunctionData() (more info with examples) or https://abi.hashex.org/ like this enter image description here

Pass the result 8da5cb5b into Remix's calldata window. If execution was successful it worked!

To see the call result

  1. Click "Debug" on the transaction List item

  2. In debugger window fast forward transaction to the end List item

  3. Copy the returned hex value and parse it using something like https://www.convertstring.com/EncodeDecode/HexDecode enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.