cuddle-1.1.0.0: example/cddl-files/shelley.cddl
; Shelley Types
block =
[ header
, transaction_bodies : [* transaction_body]
, transaction_witness_sets : [* transaction_witness_set]
, transaction_metadata_set :
{ * transaction_index => transaction_metadata }
]; Valid blocks must also satisfy the following two constraints:
; 1) the length of transaction_bodies and transaction_witness_sets
; must be the same
; 2) every transaction_index must be strictly smaller than the
; length of transaction_bodies
transaction =
[ transaction_body
, transaction_witness_set
, transaction_metadata / null
]
transaction_index = uint .size 2
header =
[ header_body
, body_signature : $kes_signature
]
header_body =
[ block_number : uint
, slot : uint
, prev_hash : $hash32 / null
, issuer_vkey : $vkey
, vrf_vkey : $vrf_vkey
, nonce_vrf : $vrf_cert
, leader_vrf : $vrf_cert
, block_body_size : uint
, block_body_hash : $hash32 ; merkle triple root
, operational_cert
, protocol_version
]
operational_cert =
( hot_vkey : $kes_vkey
, sequence_number : uint
, kes_period : uint
, sigma : $signature
)
next_major_protocol_version = 3
major_protocol_version = 1..next_major_protocol_version
protocol_version = (major_protocol_version, uint)
transaction_body =
{ 0 : set<transaction_input>
, 1 : [* transaction_output]
, 2 : coin ; fee
, 3 : uint ; ttl
, ? 4 : [* certificate]
, ? 5 : withdrawals
, ? 6 : update
, ? 7 : metadata_hash
}
transaction_input = [ transaction_id : $hash32
, index : uint
]
transaction_output = [address, amount : coin]
; address = bytes
; reward_account = bytes
; address format:
; [ 8 bit header | payload ];
;
; shelley payment addresses:
; bit 7: 0
; bit 6: base/other
; bit 5: pointer/enterprise [for base: stake cred is keyhash/scripthash]
; bit 4: payment cred is keyhash/scripthash
; bits 3-0: network id
;
; reward addresses:
; bits 7-5: 111
; bit 4: credential is keyhash/scripthash
; bits 3-0: network id
;
; byron addresses:
; bits 7-4: 1000
; 0000: base address: keyhash28,keyhash28
; 0001: base address: scripthash28,keyhash28
; 0010: base address: keyhash28,scripthash28
; 0011: base address: scripthash28,scripthash28
; 0100: pointer address: keyhash28, 3 variable length uint
; 0101: pointer address: scripthash28, 3 variable length uint
; 0110: enterprise address: keyhash28
; 0111: enterprise address: scripthash28
; 1000: byron address
; 1110: reward account: keyhash28
; 1111: reward account: scripthash28
; 1001 - 1101: future formats
certificate =
[ stake_registration
// stake_deregistration
// stake_delegation
// pool_registration
// pool_retirement
// genesis_key_delegation
// move_instantaneous_rewards_cert
]
stake_registration = (0, stake_credential)
stake_deregistration = (1, stake_credential)
stake_delegation = (2, stake_credential, pool_keyhash)
pool_registration = (3, pool_params)
pool_retirement = (4, pool_keyhash, epoch)
genesis_key_delegation = (5, genesishash, genesis_delegate_hash, vrf_keyhash)
move_instantaneous_rewards_cert = (6, move_instantaneous_reward)
move_instantaneous_reward = [ 0 / 1, { * stake_credential => coin } ]
; The first field determines where the funds are drawn from.
; 0 denotes the reserves, 1 denotes the treasury.
stake_credential =
[ 0, addr_keyhash
// 1, scripthash
]
pool_params = ( operator: pool_keyhash
, vrf_keyhash: vrf_keyhash
, pledge: coin
, cost: coin
, margin: unit_interval
, reward_account: reward_account
, pool_owners: set<addr_keyhash>
, relays: [* relay]
, pool_metadata: pool_metadata / null
)
port = uint .le 65535
ipv4 = bytes .size 4
ipv6 = bytes .size 16
dns_name = tstr .size (0..64)
single_host_addr = ( 0
, port / null
, ipv4 / null
, ipv6 / null
)
single_host_name = ( 1
, port / null
, dns_name ; An A or AAAA DNS record
)
multi_host_name = ( 2
, dns_name ; A SRV DNS record
)
relay =
[ single_host_addr
// single_host_name
// multi_host_name
]
pool_metadata = [url, metadata_hash]
url = tstr .size (0..64)
withdrawals = { * reward_account => coin }
update = [ proposed_protocol_parameter_updates
, epoch
]
proposed_protocol_parameter_updates =
{ * genesishash => protocol_param_update }
protocol_param_update =
{ ? 0: uint ; minfee A
, ? 1: uint ; minfee B
, ? 2: uint ; max block body size
, ? 3: uint ; max transaction size
, ? 4: uint ; max block header size
, ? 5: coin ; key deposit
, ? 6: coin ; pool deposit
, ? 7: epoch ; maximum epoch
, ? 8: uint ; n_opt: desired number of stake pools
, ? 9: rational ; pool pledge influence
, ? 10: unit_interval ; expansion rate
, ? 11: unit_interval ; treasury growth rate
, ? 12: unit_interval ; d. decentralization constant
, ? 13: $nonce ; extra entropy
, ? 14: [protocol_version] ; protocol version
, ? 15: coin ; min utxo value
}
transaction_witness_set =
{ ?0 => [* vkeywitness ]
, ?1 => [* multisig_script ]
, ?2 => [* bootstrap_witness ]
; In the future, new kinds of witnesses can be added like this:
; , ?3 => [* monetary_policy_script ]
; , ?4 => [* plutus_script ]
}
transaction_metadatum =
{ * transaction_metadatum => transaction_metadatum }
/ [ * transaction_metadatum ]
/ int
/ bytes .size (0..64)
/ text .size (0..64)
transaction_metadatum_label = uint
transaction_metadata =
{ * transaction_metadatum_label => transaction_metadatum }
vkeywitness = [ $vkey, $signature ]
bootstrap_witness =
[ public_key : $vkey
, signature : $signature
, chain_code : bytes .size 32
, attributes : bytes
]
multisig_script =
[ multisig_pubkey
// multisig_all
// multisig_any
// multisig_n_of_k
]
multisig_pubkey = (0, addr_keyhash)
multisig_all = (1, [ * multisig_script ])
multisig_any = (2, [ * multisig_script ])
multisig_n_of_k = (3, n: uint, [ * multisig_script ])
coin = uint
epoch = uint
addr_keyhash = $hash28
genesis_delegate_hash = $hash28
pool_keyhash = $hash28
genesishash = $hash28
vrf_keyhash = $hash32
metadata_hash = $hash32
; To compute a script hash, note that you must prepend
; a tag to the bytes of the script before hashing.
; The tag is determined by the language.
; In the Shelley era there is only one such tag,
; namely "\x00" for multisig scripts.
scripthash = $hash28
$nonce /= [ 0 // 1, bytes .size 32 ]
$hash28 /= bytes .size 28
$hash32 /= bytes .size 32
$vkey /= bytes .size 32
$vrf_vkey /= bytes .size 32
$vrf_cert /= [bytes, bytes .size 80]
$kes_vkey /= bytes .size 32
$kes_signature /= bytes .size 448
signkeyKES = bytes .size 64
$signature /= bytes .size 64
finite_set<a> = [* a]
;unit_interval = #6.30([uint, uint])
unit_interval = #6.30([1, 2])
; real unit_interval is: #6.30([uint, uint])
; but this produces numbers outside the unit interval
; and can also produce a zero in the denominator
rational = #6.30([uint, uint])
set<a> = [* a]
address = bytes
reward_account = bytes