Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 10 2017 22:42
    @jpitts banned @etherchamp1_twitter
  • Jun 05 2016 10:33
    @chriseth banned @adamskee
Piper Merriam
@pipermerriam
user defined? not defined at compile time
RJ Catalano
@VoR0220
okay. What would a use case of this be? Not sure I’m seeing it.
RJ Catalano
@VoR0220
ahhhh….okay….I can see why that would be useful for it.
Piper Merriam
@pipermerriam
yeah, predefined API for stepping through a computation, but it operates on local state
something like that, I'm still working out the details
RJ Catalano
@VoR0220
interesting…very…very…interesting.
ethers
@ethers
implementing an alias has been done several times with Solidity (selfdestruct, byte), so one for sha3 won't be that different. The team needs input on what the alias should be ethereum/solidity#363 Most here are probably familiar with Ethereum's use of Keccak-256 but for new people looking at Solidity code , it won't be obvious...
chriseth
@chriseth
@illya13 don't use for (var i = 0; i < array.length ; i++), use for (uint i = 0; i < array.length; i++)
agatsoh
@agatsoh
is there a string(somevar) constructor just like there is a uint contructor ?
or may be a bytes(somevar) contructor ?
I think its not there.
Nick
@nickmelis
if there’s a bytes(address) please let me know, that’s exactly what I’m looking for :)
agatsoh
@agatsoh
@nickmelis i verified on browser solidity . Seems like not there.
Nick
@nickmelis
@agatsoh I know, I’m still trying to find a way to convert addresses to bytes
chriseth
@chriseth
function toBytes(address x) returns (bytes b) { b = new bytes(20); for (uint i = 0; i < 20; i++) b[i] = byte(uint8(uint(x) / (2**(19 - 8 * i)))); }
agatsoh
@agatsoh
@nickmelis i dont know your use case but when i have to return addresses , i return address[] successfully. what is the use case where you have to convert address to bytes ? It might be helpful for me in future thats why i am asking.
This message was deleted
Nick
@nickmelis
@chriseth, what I get back is: "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000141f4e670000000000000000000000000000000000000000000000000000000000"
@agatsoh I have a contract which contains an array of structs. The structs has an address and some data (bytes). I am trying to find a way to return the whole array. Given you can’t return internal structures, I am trying to concatenate everyting into a big bytes string
agatsoh
@agatsoh
@nickmelis vow that seems to be a very valid one. which i would definitely come across in the future.
Nick
@nickmelis
you also cannot return bytes[], so what I do is I concatenate all the bytes/string in the array into one big string and return it
just need to do the same for mixed types (bytes + addresses)
agatsoh
@agatsoh
cant you define a constant function where you make a local dynamic address[] and return them?
chriseth
@chriseth
function toBytes(address x) returns (bytes b) { b = new bytes(20); for (uint i = 0; i < 20; i++) b[i] = byte(uint8(uint(x) / (2**(8*(19 - i))))); }
agatsoh
@agatsoh
and separately concatenate bytes and return them in separate function.
Nick
@nickmelis
@chriseth awesome!!!
that works perfectly!
thanks a lot!!!
Illya Havsiyevych
@illya13
@chriseth why var i is bad ?
chriseth
@chriseth
@illya13 var i = 0 is the same as uint8 i = 0, because uint8 is the smallest type that can hold 0
Illya Havsiyevych
@illya13
but uint8 is ok for my case
what about internals / performance of VM
is it using uint internally ?
chriseth
@chriseth
in terms of gas, uint is best. In terms of performance, uint8 might be better
Illya Havsiyevych
@illya13
ok, thx
agatsoh
@agatsoh
I have contract and have functions like this
mapping(address => bytes) flags;
function set_flags(address user,bytes flags) returns (uint16)
    {    

        flags[user] = flags;
        return status["OK"];
    }
flags is a contract variable
This message was deleted
This message was deleted
This message was deleted
Untitled2:462:9: Error: Type address is not implicitly convertible to expected type uint256.
        flags[user] = flags;
                    ^--^

Untitled2:462:17: Error: Type bytes memory is not implicitly convertible to expected type bytes1.
        flags[user] = flags;
                                  ^---^
agatsoh
@agatsoh
I am getting these errors on the same line
Can someone tell me what I am doing wrong ?
Solved it please dont look into it.
agatsoh
@agatsoh
I have a Gateway contract which I am calling from another contract. Does this error strinke a chord with someone?
Untitled2:414:3: Error: Different number of arguments in return statement than in returns declaration.
        return Gateway(users[user]).get_flags(user);
        ^-----------------------------------------^
chriseth
@chriseth
@agatsoh probably related to dynamic data in calls
you cannot return arrays (including string and bytes) to other contracts as a limitation of the EVM
agatsoh
@agatsoh
can function return bytes @chriseth ?