JSON RPC Call using ETH getStorage
Task Details : Make a JSON RPC call using eth_getStorageAt() to get the first storage variable (slot #0) of any deployed smart contract
Within the scripts folder, create a file called
getStorage.js
Let's write our
getStorage.js
script
Execute the following command in your terminal to run the getStorage script using the Swisstronik network
Execute the following command in your terminal to run the getStorage script using the ETH Sepolia network
Execute the following command in your terminal to run the getStorage script using the Polygon Mumbai network
Upon successful execution, your terminal should display the latest message you've defined in the contract 🎉
01. Provide an explanation of the value retrieved from the RPC call.
✅ Swisstronik Network:
✔ Value: 0xc73e7f645a2bf1365a0903afa03a2cb5029ba989df7844b0fe7751b1ba918ea4
✔ Explanation: This hexadecimal string represents the raw data stored in the contract's first storage slot, which corresponds to the private message variable. The value 0xc73e7f645a2bf1365a0903afa03a2cb5029ba989df7844b0fe7751b1ba918ea4 encodes the current message stored in the contract. This value can change when someone calls the setMessage() function to update the message.
✅ Mumbai Network and Sepolia Network:
✔ Value: 0x0000000000000000000000000000000000000000000000000000000000000000
✔ Explanation: These values are also hexadecimal strings, but they consist entirely of zeros. This suggests that either no meaningful data was stored in the first storage slot of the contract on these networks. Essentially, it indicates that there is no message stored in the contract on these networks, or the message is an empty string.
02. What does this retrieved value represent? Is there any difference if this RPC call is made on the Sepolia or Mumbai networks?
✅ Swisstronik Network, you are seeing the encoded or hashed representation of the current message stored in the contract's first storage slot.
✅ Mumbai and Sepolia Networks, you are seeing all zeros in the first storage slot, indicating an empty message or no message has been set on these networks for the given contract.
Last updated
Was this helpful?