22

I tried this

contract MyContract{
    bytes public data = 0x3333;

    function clearData(){
         data = 0x;
    }
}

But solc doesn't like me trying to set data to 0x

Akhil F
  • 1,928
  • 3
  • 19
  • 29

2 Answers2

24

Use "".

contract MyContract{
    bytes public data = "0x3333";
    bytes public empty;

    function clearData(){
         data = "";
    }
}

Tested using https://ethereum.github.io/browser-solidity by looking at the value of data and empty.

eth
  • 85,679
  • 53
  • 285
  • 406
3

delete data;

Source http://solidity.readthedocs.io/en/develop/types.html

delete a assigns the initial value for the type to a. I.e. for integers it is equivalent to a = 0, but it can also be used on arrays, where it assigns a dynamic array of length zero or a static array of the same length with all elements reset. For structs, it assigns a struct with all members reset.

William Entriken
  • 4,690
  • 15
  • 42