5

I want to create a contract with a hardcoded bytes variable.

contract Test(){
   function Test(){
      bytes x = 0x..... //greater than 32 bytes 
   }
}

The above returns a Type int_const not implicitly convertible to expected type bytes storage pointer error.

4
contract C1 {
    function f1() returns(bytes) {
        bytes memory bb = "\x00\x01\x02";  // you can extend this
        return(bb);
    }
}

Tested using online Solidity Browser, output is:

Result: "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030001020000000000000000000000000000000000000000000000000000000000"
Cost: 25630 gas. 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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