thirdweb-dev/docs

A suggestion for updating the "useContractRead" documentation.

Sandeepreddyr12 opened this issue · 1 comments

Issue: When using the read functions (via useContractRead), the sender address is not automatically sent, causing msg.sender to be inaccessible to any view function within the smart contract. To work around this, I must explicitly fetch and pass the address using the "from" property in overrides. demonstrated in the image below calling the function with and without "from" property in overrides.

[Image: Image with and without Overrides]
Screenshot 2023-09-08 091943 (2)

Suggestion: It would be beneficial to enhance the user experience by adding a note or highlighting the importance of including the sender's address in view functions. Furthermore, consider implementing a boolean toggle that allows users to enable or disable the automatic forwarding of the sender's address, providing greater flexibility in contract interaction.

note:- above suggestion can be applicable to both Docs and Dashboard.

document update or any thing! please let me know, i'm happy to contribute.

Thank you.

@Sandeepreddyr12 thank your report!

It's true that its not well documented, would love a contribution in the docs repo for this!

This is the API, and a little explanation on the implication of passing it vs not would be a great addition 🙏

useContractRead(contract, "functionName", [arg1, arg2], { from: "0x..." } );