If view or pure function doesn't cost any gas, would they be abused/free ride?

The name of the pictureThe name of the pictureThe name of the pictureClash 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?










share|improve this question









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.























    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?










    share|improve this question









    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.





















      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?










      share|improve this question









      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






      share|improve this question









      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.











      share|improve this question









      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.









      share|improve this question




      share|improve this question








      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.




















          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.






          share|improve this answer




















          • 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

















          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.






          share|improve this answer




















          • 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










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "642"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          noooooooob is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          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






























          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.






          share|improve this answer




















          • 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














          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.






          share|improve this answer




















          • 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












          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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
















          • 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










          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.






          share|improve this answer




















          • 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














          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.






          share|improve this answer




















          • 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












          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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
















          • 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










          noooooooob is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          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.













           


          draft saved


          draft discarded














          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













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          List of Gilmore Girls characters

          Confectionery