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 Answer 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.