Patent Pending
This document outlines the format of the CENNZnet Doughnut Permission Domain.
A CENNZnut represents values as little-endian.
A CENNZnut contains:
- a
VERSION
definition - a
PERMISSIONS
definition
<VERSION><PERMISSIONS>
- Represented as a 16-bit value with the following structure:
- bits 0..9
- Version number
- Unsigned 10-bit integer
- bits 10..15
- Reserved/unused
- bits 0..9
Note: Subject to change
- 1 byte
module_count
- Unsigned 8-bit integer
- Increment by 1 when read (range 1 - 256)
- Modules list
- 1 byte
- bit 0
has_block_cooldown
flag
- bits 1..7
method_count
- Unsigned 7-bit integer
- Increment by 1 when read (range 1 - 128)
- bit 0
- 32 bytes
module_name
- String
- If
has_block_cooldown
- 4 bytes
block_cooldown
- Unsigned 32-bit integer
- 4 bytes
- Methods list
- 1 byte
- bit 0
has_block_cooldown
flag
- bit 1
has_pact
flag
- bit 2..7
- reserved/unused
- bit 0
- 32 bytes
method_name
- String
- If
block_cooldown
is set- 4 bytes
block_cooldown
- Unsigned 32-bit integer
- 4 bytes
- If
has_pact
is set- 1 byte
pact_length
- Unsigned 8-bit integer
- Increment by 1 when read (range 1 - 256)
pact_length
bytespact
- 1 byte
- 1 byte
- 1 byte
- 1 byte
contract_count
= value
- Contracts list
- 1 byte
- bit 0
has_block_cooldown
flag
- bits 1..7
- Reserved
- bit 0
- 32 bytes
contract_address
- If
has_block_cooldown
- 4 bytes
block_cooldown
- Unsigned 32-bit integer
- 4 bytes
- 1 byte
- Read the first byte, as
module_count
and increment it by 1 - Begin reading module list items
- Read the first byte
- Read bit 0 as
has_block_cooldown
Boolean - Read bits 1..7 as
method_count
and increment it by 1
- Read bit 0 as
- Read 32 bytes as
module_name
- If
has_block_cooldown
- Read 4 bytes as
block_cooldown
- Read 4 bytes as
- Begin reading methods list items
- Read the first byte
- Read bit 0 as
has_block_cooldown
Boolean - Read bit 1 as
has_pact
Boolean - Ignore remaining bits
- Read bit 0 as
- Read 32 bytes as
method_name
- If
has_block_cooldown
- Read 4 bytes as
block_cooldown
- Read 4 bytes as
- If
has_pact
- Read 1 byte as
pact_length
and increment it by 1- ∵ There is a bit to indicate the presence of pact constraints (i.e.,
has_pact
), which allows us to definepact_length
in the range of[0 + 1, 255 + 1]
.
- ∵ There is a bit to indicate the presence of pact constraints (i.e.,
- Read
pact_length
bytes aspact
- Read 1 byte as
- Repeat until
method_count
matches iterations
- Read the first byte
- Repeat until
module_count
matches iterations
- Read the first byte
- Read the next byte, as
contract_count
- Begin reading contract list items
- Read the first byte
- Read the bit 0 as
has_block_cooldown
Boolean
- Read the bit 0 as
- Read 32 bytes as
contract_address
- If
has_block_cooldown
- Read 4 bytes as
block_cooldown
- Read 4 bytes as
- Repeat until
contract_count
matches iterations
- Read the first byte
Any CENNZnut with smart contract permissions must also assign runtime module permissions for the contracts module:
{
"modules": {
"contracts": {
"call": {}
}
},
"contracts": {
"d0a98...56d7e9c": {},
"b2150...2f40a21": {},
}
}
- Any module named
"*"
is a wildcard- A wildcard module enables all modules
- Constraints applied to a wildcard module such as
methods
andblock_cooldown
apply - Named module constraints take priority over wildcard module constraints
- Any contract with address
[0x00; 32]
is a wildcard- A wildcard contract enables all contracts
- Constraints applied to a wildcard contract such as
block_cooldown
apply - Contraints of explicitly identified contracts take priority over contraints of a contract wildcard
- Any method named
"*"
is a wildcard- A wildcard method enables all methods for the module or contract it is listed under
- Constraints applied to a wildcard method such as
block_cooldown
andpact
apply - Named method constraints take priority over wildcard method constraints