While trying to upload a public key on Ethereum, I have faced a problem.
Given the following code in Solidity browser, it seems that I can only insert string
values (using the browser compiler). For example, when I "create" and "set" values as "0x1234", it outputs:
"0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000063078313233340000000000000000000000000000000000000000000000000000"
What I want was something like "0x1234" but instead of that it interprets as a string
. The work around is use bytesN where N is actual number of bytes. But then it becomes a static. Could anyone help?
contract SimpleStorage {
bytes storedData;
function set(bytes x) {
storedData = x;
}
function get() constant returns (bytes retVal) {
return storedData;
}
}
Yes, instead of the above code, I can do as the following where I set bytes to bytes2
. Then I can put "0x12", which would output "0x12". But Can I do it without being static?
contract SimpleStorage
{
bytes2 storedData;
function set(bytes2 x) {
storedData = x;
}
function get() constant returns (bytes2 retVal) {
return storedData;
}
}