Skip to main content
Format code
Source Link
Ismael
  • 30.3k
  • 23
  • 54
  • 97

In my contract iI have a view public function that returns an array of bytes32 elements. In remix it produces a warning saying it might run out of block gas limit if iI use this function.

As iI had read when a function doesn't make state changes you define it as view public. So when you call it you don't have to pay ether because your local node calls the variables from the contract and runs it localy. Is this right? Then why iI have to worry about gas limit?

Re-edit after Lauri's Peltonen comment. The code iI used is:

pragma solidity ^0.4.18;

contract Project{

bytes32[] array; function addValue(bytes32 element)public{ //only the administrator can add new values array.push(element); } function getAll()view public returns(bytes32[]){ return array; } }
pragma solidity ^0.4.18;
contract Project{
    bytes32[] array;
    
    function addValue(bytes32 element)public{
        //only the administrator can add new values
        array.push(element);
    }
    
    function getAll()view public returns(bytes32[]){
        return array;
    }
}

In my contract i have a view public function that returns an array of bytes32 elements. In remix it produces a warning saying it might run out of block gas limit if i use this function.

As i had read when a function doesn't make state changes you define it as view public. So when you call it you don't have to pay ether because your local node calls the variables from the contract and runs it localy. Is this right? Then why i have to worry about gas limit?

Re-edit after Lauri's Peltonen comment. The code i used is:

pragma solidity ^0.4.18;

contract Project{

bytes32[] array; function addValue(bytes32 element)public{ //only the administrator can add new values array.push(element); } function getAll()view public returns(bytes32[]){ return array; } }

In my contract I have a view public function that returns an array of bytes32 elements. In remix it produces a warning saying it might run out of block gas limit if I use this function.

As I had read when a function doesn't make state changes you define it as view public. So when you call it you don't have to pay ether because your local node calls the variables from the contract and runs it localy. Is this right? Then why I have to worry about gas limit?

Re-edit after Lauri's Peltonen comment. The code I used is:

pragma solidity ^0.4.18;
contract Project{
    bytes32[] array;
    
    function addValue(bytes32 element)public{
        //only the administrator can add new values
        array.push(element);
    }
    
    function getAll()view public returns(bytes32[]){
        return array;
    }
}
added 363 characters in body
Source Link
kathi
  • 199
  • 1
  • 12

In my contract i have a view public function that returns an array of bytes32 elements. In remix it produces a warning saying it might run out of block gas limit if i use this function.

As i had read when a function doesn't make state changes you define it as view public. So when you call it you don't have to pay ether because your local node calls the variables from the contract and runs it localy. Is this right? Then why i have to worry about gas limit?

Re-edit after Lauri's Peltonen comment. The code i used is:

 

pragma solidity ^0.4.18;

contract Project{

bytes32[] array; function addValue(bytes32 element)public{ //only the administrator can add new values array.push(element); } function getAll()view public returns(bytes32[]){ return array; } }

In my contract i have a view public function that returns an array of bytes32 elements. In remix it produces a warning saying it might run out of block gas limit if i use this function.

As i had read when a function doesn't make state changes you define it as view public. So when you call it you don't have to pay ether because your local node calls the variables from the contract and runs it localy. Is this right? Then why i have to worry about gas limit?

 

In my contract i have a view public function that returns an array of bytes32 elements. In remix it produces a warning saying it might run out of block gas limit if i use this function.

As i had read when a function doesn't make state changes you define it as view public. So when you call it you don't have to pay ether because your local node calls the variables from the contract and runs it localy. Is this right? Then why i have to worry about gas limit?

Re-edit after Lauri's Peltonen comment. The code i used is:

pragma solidity ^0.4.18;

contract Project{

bytes32[] array; function addValue(bytes32 element)public{ //only the administrator can add new values array.push(element); } function getAll()view public returns(bytes32[]){ return array; } }
Source Link
kathi
  • 199
  • 1
  • 12

Gas consumption of a view public function

In my contract i have a view public function that returns an array of bytes32 elements. In remix it produces a warning saying it might run out of block gas limit if i use this function.

As i had read when a function doesn't make state changes you define it as view public. So when you call it you don't have to pay ether because your local node calls the variables from the contract and runs it localy. Is this right? Then why i have to worry about gas limit?