If view or pure function doesn't cost any gas, would they be abused/free ride?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
So if I understand this correctly, view
function only read data from ethereum and doesn't mutate any state and pure
function doesn't even read data and they are intended for cases like return 1+1;
If this is the case, would they be abused since they don't cost any gas? Like could I just use them for free computation? What happen if I have a infinite loop in a view or pure function?
go-ethereum gas gas-limit
New contributor
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
So if I understand this correctly, view
function only read data from ethereum and doesn't mutate any state and pure
function doesn't even read data and they are intended for cases like return 1+1;
If this is the case, would they be abused since they don't cost any gas? Like could I just use them for free computation? What happen if I have a infinite loop in a view or pure function?
go-ethereum gas gas-limit
New contributor
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
So if I understand this correctly, view
function only read data from ethereum and doesn't mutate any state and pure
function doesn't even read data and they are intended for cases like return 1+1;
If this is the case, would they be abused since they don't cost any gas? Like could I just use them for free computation? What happen if I have a infinite loop in a view or pure function?
go-ethereum gas gas-limit
New contributor
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
So if I understand this correctly, view
function only read data from ethereum and doesn't mutate any state and pure
function doesn't even read data and they are intended for cases like return 1+1;
If this is the case, would they be abused since they don't cost any gas? Like could I just use them for free computation? What happen if I have a infinite loop in a view or pure function?
go-ethereum gas gas-limit
go-ethereum gas gas-limit
New contributor
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 10 mins ago
New contributor
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 8 hours ago


noooooooob
1064
1064
New contributor
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
noooooooob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
5
down vote
pure
and view
functions only are "free" when you call them externally, as in you call that function by itself and run the calculation on your node. So if you had a function that returned "1+1", yes you can call that individual view function as many times as you want for free, even without creating a transaction.
However, if you use a view
or pure
function within an internal function which DOES cost gas, you will be charged for those calculations like normal.
Thanks for the insight. Is it possible to invoke the bad pure function not using my own node ? Would that still be consider abuse or free ride ? Does the network penalize such behavior in anyway?
– noooooooob
13 mins ago
add a comment |Â
up vote
3
down vote
Just to add to @Shawn's good answer.
Yes, you can abuse them. But as the pure
and view
computations are performed only on your own node you would only hurt your own node. You would not hurt the Ethereum network in any way. If you call the function(s) enough, you might even crash your node but it still wouldn't hurt the network in any way.
Say if I call my contract via web 3 without my own node, would that affect the network in anyway?
– noooooooob
16 mins ago
No, you always have to call some node, so only the called node is affected. You can't access the blockchain without an intermediary node.
– Lauri Peltonen
15 mins ago
Hmm .. Bear with my ignorance. My understanding is that when you use dapp, you access the free node hosted by infura via web3 ?
– noooooooob
11 mins ago
Infura is one way, yes. They provide you with a node you can use. But there are many other alternatives.
– Lauri Peltonen
10 mins ago
So is it fair to say that we could free ride the computation of pure/view function when we are not running our own node? Eg. Could I run expensive number crunch task on one of the network node for free ?
– noooooooob
7 mins ago
 |Â
show 1 more comment
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
pure
and view
functions only are "free" when you call them externally, as in you call that function by itself and run the calculation on your node. So if you had a function that returned "1+1", yes you can call that individual view function as many times as you want for free, even without creating a transaction.
However, if you use a view
or pure
function within an internal function which DOES cost gas, you will be charged for those calculations like normal.
Thanks for the insight. Is it possible to invoke the bad pure function not using my own node ? Would that still be consider abuse or free ride ? Does the network penalize such behavior in anyway?
– noooooooob
13 mins ago
add a comment |Â
up vote
5
down vote
pure
and view
functions only are "free" when you call them externally, as in you call that function by itself and run the calculation on your node. So if you had a function that returned "1+1", yes you can call that individual view function as many times as you want for free, even without creating a transaction.
However, if you use a view
or pure
function within an internal function which DOES cost gas, you will be charged for those calculations like normal.
Thanks for the insight. Is it possible to invoke the bad pure function not using my own node ? Would that still be consider abuse or free ride ? Does the network penalize such behavior in anyway?
– noooooooob
13 mins ago
add a comment |Â
up vote
5
down vote
up vote
5
down vote
pure
and view
functions only are "free" when you call them externally, as in you call that function by itself and run the calculation on your node. So if you had a function that returned "1+1", yes you can call that individual view function as many times as you want for free, even without creating a transaction.
However, if you use a view
or pure
function within an internal function which DOES cost gas, you will be charged for those calculations like normal.
pure
and view
functions only are "free" when you call them externally, as in you call that function by itself and run the calculation on your node. So if you had a function that returned "1+1", yes you can call that individual view function as many times as you want for free, even without creating a transaction.
However, if you use a view
or pure
function within an internal function which DOES cost gas, you will be charged for those calculations like normal.
answered 8 hours ago


Shawn Tabrizi
2,6551320
2,6551320
Thanks for the insight. Is it possible to invoke the bad pure function not using my own node ? Would that still be consider abuse or free ride ? Does the network penalize such behavior in anyway?
– noooooooob
13 mins ago
add a comment |Â
Thanks for the insight. Is it possible to invoke the bad pure function not using my own node ? Would that still be consider abuse or free ride ? Does the network penalize such behavior in anyway?
– noooooooob
13 mins ago
Thanks for the insight. Is it possible to invoke the bad pure function not using my own node ? Would that still be consider abuse or free ride ? Does the network penalize such behavior in anyway?
– noooooooob
13 mins ago
Thanks for the insight. Is it possible to invoke the bad pure function not using my own node ? Would that still be consider abuse or free ride ? Does the network penalize such behavior in anyway?
– noooooooob
13 mins ago
add a comment |Â
up vote
3
down vote
Just to add to @Shawn's good answer.
Yes, you can abuse them. But as the pure
and view
computations are performed only on your own node you would only hurt your own node. You would not hurt the Ethereum network in any way. If you call the function(s) enough, you might even crash your node but it still wouldn't hurt the network in any way.
Say if I call my contract via web 3 without my own node, would that affect the network in anyway?
– noooooooob
16 mins ago
No, you always have to call some node, so only the called node is affected. You can't access the blockchain without an intermediary node.
– Lauri Peltonen
15 mins ago
Hmm .. Bear with my ignorance. My understanding is that when you use dapp, you access the free node hosted by infura via web3 ?
– noooooooob
11 mins ago
Infura is one way, yes. They provide you with a node you can use. But there are many other alternatives.
– Lauri Peltonen
10 mins ago
So is it fair to say that we could free ride the computation of pure/view function when we are not running our own node? Eg. Could I run expensive number crunch task on one of the network node for free ?
– noooooooob
7 mins ago
 |Â
show 1 more comment
up vote
3
down vote
Just to add to @Shawn's good answer.
Yes, you can abuse them. But as the pure
and view
computations are performed only on your own node you would only hurt your own node. You would not hurt the Ethereum network in any way. If you call the function(s) enough, you might even crash your node but it still wouldn't hurt the network in any way.
Say if I call my contract via web 3 without my own node, would that affect the network in anyway?
– noooooooob
16 mins ago
No, you always have to call some node, so only the called node is affected. You can't access the blockchain without an intermediary node.
– Lauri Peltonen
15 mins ago
Hmm .. Bear with my ignorance. My understanding is that when you use dapp, you access the free node hosted by infura via web3 ?
– noooooooob
11 mins ago
Infura is one way, yes. They provide you with a node you can use. But there are many other alternatives.
– Lauri Peltonen
10 mins ago
So is it fair to say that we could free ride the computation of pure/view function when we are not running our own node? Eg. Could I run expensive number crunch task on one of the network node for free ?
– noooooooob
7 mins ago
 |Â
show 1 more comment
up vote
3
down vote
up vote
3
down vote
Just to add to @Shawn's good answer.
Yes, you can abuse them. But as the pure
and view
computations are performed only on your own node you would only hurt your own node. You would not hurt the Ethereum network in any way. If you call the function(s) enough, you might even crash your node but it still wouldn't hurt the network in any way.
Just to add to @Shawn's good answer.
Yes, you can abuse them. But as the pure
and view
computations are performed only on your own node you would only hurt your own node. You would not hurt the Ethereum network in any way. If you call the function(s) enough, you might even crash your node but it still wouldn't hurt the network in any way.
answered 6 hours ago
Lauri Peltonen
3,1631319
3,1631319
Say if I call my contract via web 3 without my own node, would that affect the network in anyway?
– noooooooob
16 mins ago
No, you always have to call some node, so only the called node is affected. You can't access the blockchain without an intermediary node.
– Lauri Peltonen
15 mins ago
Hmm .. Bear with my ignorance. My understanding is that when you use dapp, you access the free node hosted by infura via web3 ?
– noooooooob
11 mins ago
Infura is one way, yes. They provide you with a node you can use. But there are many other alternatives.
– Lauri Peltonen
10 mins ago
So is it fair to say that we could free ride the computation of pure/view function when we are not running our own node? Eg. Could I run expensive number crunch task on one of the network node for free ?
– noooooooob
7 mins ago
 |Â
show 1 more comment
Say if I call my contract via web 3 without my own node, would that affect the network in anyway?
– noooooooob
16 mins ago
No, you always have to call some node, so only the called node is affected. You can't access the blockchain without an intermediary node.
– Lauri Peltonen
15 mins ago
Hmm .. Bear with my ignorance. My understanding is that when you use dapp, you access the free node hosted by infura via web3 ?
– noooooooob
11 mins ago
Infura is one way, yes. They provide you with a node you can use. But there are many other alternatives.
– Lauri Peltonen
10 mins ago
So is it fair to say that we could free ride the computation of pure/view function when we are not running our own node? Eg. Could I run expensive number crunch task on one of the network node for free ?
– noooooooob
7 mins ago
Say if I call my contract via web 3 without my own node, would that affect the network in anyway?
– noooooooob
16 mins ago
Say if I call my contract via web 3 without my own node, would that affect the network in anyway?
– noooooooob
16 mins ago
No, you always have to call some node, so only the called node is affected. You can't access the blockchain without an intermediary node.
– Lauri Peltonen
15 mins ago
No, you always have to call some node, so only the called node is affected. You can't access the blockchain without an intermediary node.
– Lauri Peltonen
15 mins ago
Hmm .. Bear with my ignorance. My understanding is that when you use dapp, you access the free node hosted by infura via web3 ?
– noooooooob
11 mins ago
Hmm .. Bear with my ignorance. My understanding is that when you use dapp, you access the free node hosted by infura via web3 ?
– noooooooob
11 mins ago
Infura is one way, yes. They provide you with a node you can use. But there are many other alternatives.
– Lauri Peltonen
10 mins ago
Infura is one way, yes. They provide you with a node you can use. But there are many other alternatives.
– Lauri Peltonen
10 mins ago
So is it fair to say that we could free ride the computation of pure/view function when we are not running our own node? Eg. Could I run expensive number crunch task on one of the network node for free ?
– noooooooob
7 mins ago
So is it fair to say that we could free ride the computation of pure/view function when we are not running our own node? Eg. Could I run expensive number crunch task on one of the network node for free ?
– noooooooob
7 mins ago
 |Â
show 1 more comment
noooooooob is a new contributor. Be nice, and check out our Code of Conduct.
noooooooob is a new contributor. Be nice, and check out our Code of Conduct.
noooooooob is a new contributor. Be nice, and check out our Code of Conduct.
noooooooob is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f59036%2fif-view-or-pure-function-doesnt-cost-any-gas-would-they-be-abused-free-ride%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password