Hot answers tagged

2

tl;dr: we serialize the michelson value to binary, we then hash those bytes it with Blake2b-256. We base58 encode the result. Long version Let's consider the case of the Ledger Blake2b has of the integer 1, as given by: $ tezos-client hash data 1 of type int Raw packed data: 0x050001 Script-expression-ID-Hash: ...


2

There is no instruction in Michelson to interpret arbitrary bytes as numbers. The simplest way to achieve what you want is to use a constant table (as a Michelson map) from bytes of length 1 to their values (between 0 and 255). Then, depending on how uniform you need your distribution to be, you can either take a modulo on the value of the last byte of your ...


1

So my specific questions: Is there a way to get the next block hash within a smart contract? No, there is no instruction in Michelson to query a block hash. Or some other way to get a value that isn't known at the time the contract is called? You could use the CREATE_CONTRACT instruction that is usually meant to originate a new contract, it returns the ...


1

You can test against the data that the official Tezos project uses for regression testing. This file might be of interest: https://gitlab.com/tezos/tezos/-/blob/master/tezt/_regressions/protocol.alpha.operation.internal.out


Only top voted, non community-wiki answers of a minimum length are eligible