1

I have written simple function in remix.

pragma solidity ^0.5.0;

    contract testCompile{
        string myString = "Hello World";

        function showString() public view returns (string memory){
            return myString;
        }        
    }

but it shows warning about infinite gas price. How can i resolve this case!

1 Answers1

1

Strings are unbounded and can basically have any lenght of text inside. Therefore the compiler has no way of knowing how much gas a transaction with strings will consume and will give you the worst case scenario as a warning (https://ethereum.stackexchange.com/a/34588/31933).

You can either ignore the warning or use some other type which is restricted, such as some bytes variant.

Lauri Peltonen
  • 29,391
  • 3
  • 20
  • 57