ethglobal / nfthack-support

Issue tracker for NFTHack support
5 stars 2 forks source link

Why does scaffold-eth send a transaction to get the tokenURI? #7

Open jlw264 opened 3 years ago

jlw264 commented 3 years ago

If I understand right, tokenURI(tokenId) is inherited from the ERC721 contract and anyone should be able to read it (without charging gas). Why does scaffold-eth make me send a transaction to get this? Is something wrong with my ABI?

Link to my contract: https://github.com/jlw264/farmed-particles/blob/main/packages/hardhat/contracts/FarmedParticle.sol

See bottom of screen in below picture:

Capture

Pongch commented 3 years ago

hey @jlw264, you are correct that most view transaction should incur gas, however you will need to specify view on the function signature, otherwise it will consider the transaction state-changing and charge gas

which function did you call to fetch tokenURI?

tenthirtyone commented 3 years ago

It's likely a function call, not call a transactions

https://ethereum.stackexchange.com/questions/765/what-is-the-difference-between-a-transaction-and-a-call#:~:text=transactions%20are%20created%20by%20your,which%20alone%20evaluates%20the%20result.