There are dozen of sources on the internet that state the
view functions, which are called externally (i.e. from oustide of contract), that do not call other contracts' functions and do not change the state of the contract - consume no GAS. As long as the call is done on a
I would like to hear some clarifications about what exactly considered to be a
local node and what is a
remote node. And how exactly does it work with
Is the node only considered
localwhen is run on local machine resources? i.e. addressed by
web3.jsby the domain name
Is the node still considered
local, if I host it on
Azureservices? i.e. it's my own
localnode, which is publicly available in order to use it in the front-end. I no longer use the "localhost" domain to access it. But I want to use it in order to avoid paying GAS for
If I use a remote node such as
infura- then do
viewfunctions start costing GAS?
(in in case answer to previous question is yes) Is this possible to publish my own
localnode (essentially making it a remote node), so the client would still be able to call it and spend no-gas on
In cases when functions (otherwise-free when called locally) start costing GAS - is the cost taken from the contract?
In cases when functions (otherwise-free when called locally) start costing GAS - does the
transactionto cover the cost? (connected to previous question)
Is it so that when
web3.jsis used on the
front-endthen node is always
remote. And when
web3.jsis used on the
back-end, then the node is always
local(unless local is not available, of course)?
How do you use
front-end, to allow users querying
non-state-changingcontract functions without a cost? I guess this is my main question which kind of summarizes why I have so much confusion about local/remote node. :)
(optional - dApp architecture advice). Could you tell if there is a flaw or a global misconception in my understanding? If we always use the
remotenodes on the
front-endthen there is no "free" transactions/calls by definition. It looks like there should always be an interface on top of the backend that accepts the "calls" from the front-end, essentially making them GAS-free. So there are always 2 instances of
web3.jsrunning. 1st - is the one that client uses to create paid transactions, 2nd - is running on the backend to make GAS-free calls that do not change state. Unless it is possible to make front-end
web3.jsto tell the node to use local resources for free.
Backstory: I am working on my first contract and I am new in the world of
blockchain. I want to expose my contract on the internet so the user would be able to "work" with it. I don't want the user (or the contract itself) to pay for the view (non-state-changing) functions. Sorry if some questions are stupid. I don't own a node or a website (yet) :)
Please do not mark the topic as duplicate unless all questions are answered in the linked topic. Thank you.