Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data OriginationOperation = forall cp st.(StorageScope st, ParameterScope cp) => OriginationOperation {
- ooOriginator :: Address
- ooDelegate :: Maybe KeyHash
- ooBalance :: Mutez
- ooStorage :: Value st
- ooContract :: Contract cp st
- mkOriginationOperationHash :: OriginationOperation -> OperationHash
- newtype OperationHash = OperationHash {}
- mkContractAddress :: OperationHash -> OriginationIndex -> GlobalCounter -> Address
Documentation
data OriginationOperation Source #
Data necessary to originate a contract.
forall cp st.(StorageScope st, ParameterScope cp) => OriginationOperation | |
|
Instances
Show OriginationOperation Source # | |
Defined in Michelson.Typed.Origination showsPrec :: Int -> OriginationOperation -> ShowS # show :: OriginationOperation -> String # showList :: [OriginationOperation] -> ShowS # |
mkOriginationOperationHash :: OriginationOperation -> OperationHash Source #
Construct OperationHash
for an OriginationOperation
.
Operation hashing
newtype OperationHash Source #
Instances
mkContractAddress :: OperationHash -> OriginationIndex -> GlobalCounter -> Address Source #
Compute address of a contract from its origination operation, origination index and global counter.
However, in real Tezos encoding of the operation is more than just OriginationOperation
.
There an Operation has several more meta-fields plus a big sum-type of all possible operations.
What is important is that one (big) Operation may lead to origination of multiple contracts. That is why contract address is constructed from hash of the operation that originated and of index of the contract's origination in the execution of that operation.
In other words, contract hash is calculated as the blake2b160 (20-byte) hash of origination operation hash + int32 origination index + word64 global counter.
In Morley we do not yet support full encoding of Tezos Operations, therefore we choose to generate contract addresses in a simplified manner.
Namely, we encode OriginationOperation
as we can and concat it with the origination index
and the global counter.
Then we take blake2b160
hash of the resulting bytes and consider it to be the contract's
address.