If view or pure function doesn't cost any gas, would they be abused?
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
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
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
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
New contributor
New contributor
asked 2 hours ago
noooooooob
1063
1063
New contributor
New contributor
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
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.
add a comment |Â
up vote
0
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.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
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.
add a comment |Â
up vote
3
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.
add a comment |Â
up vote
3
down vote
up vote
3
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 2 hours ago
Shawn Tabrizi
2,6351320
2,6351320
add a comment |Â
add a comment |Â
up vote
0
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.
add a comment |Â
up vote
0
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.
add a comment |Â
up vote
0
down vote
up vote
0
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 29 mins ago
Lauri Peltonen
3,1321319
3,1321319
add a comment |Â
add a 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%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