0

As known, reading view functions is free, but is it also free if I use it between two contract? Let's say I have a contract Registry which has mapping that stores string => uint, nextly I pay some wei for a transaction "setValue" to set "test" => 5.

Now I make a new contract, load Registry and call view function "getValue" with argument "test". Will it cost an extra wei, more than using for example enum which will return me 5? Using global registry contract can be extremely handy, especially with web3js, but I wonder if this convenience costs extra gas.

0

If the read is within a transaction that is signed and mined in a block, then no, it's not free. The costs are the same costs as if it wasn't labeled view. The gas free is only for functions called with eth_call.

0

In general, the transaction initiator pays all the fees.

So for example, if an account @account1 sends a transaction to a contract A and contract A by its turn calls a function b() in another contract B, then @account1 will have to pay the sum of the used resources in all the involved transactions and function calls.

This means that if b() is a view function, there's no additional gas cost. Otherwise its cost will be added up to the initial transaction and @account1 will have to pay.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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