Skip to main content

The governance Contract

The governance contract is one of the core contracts on each IOTA Smart Contracts chain.

The governance contract provides the following functionalities:

  • It defines the identity set that constitutes the state controller (the entity that owns the state output via the chain Alias Address). It is possible to add/remove addresses from the state controller (thus rotating the committee of validators).
  • It defines the chain owner (the L1 entity that owns the chain - initially whoever deployed it). The chain owner can collect special fees and customize some chain-specific parameters.
  • It defines the entities allowed to have an access node.
  • It defines the fee policy for the chain (gas price, what token is used to pay for gas, and the validator fee share).

Entry Points​

rotateStateController​

Called when the committee is about to be rotated to the new address newStateControllerAddr.

If it succeeds, the next state transition will become a governance transition, thus updating the state controller in the chain's Alias Output. If it fails, nothing happens.

It can only be invoked by the chain owner.

Parameters​

NameTypeOptionalDescription
newStateControllerAddr[u8; 32]NoThe address of the next state controller. Must be an allowed state controller address

Returns​

None

addAllowedStateControllerAddress​

Adds the address stateControllerAddress to the list of identities that constitute the state controller.

It can only be invoked by the chain owner.

Parameters​

NameTypeOptionalDescription
stateControllerAddress[u8; 32]NoThe address to add to the set of allowed state controllers

Returns​

None

removeAllowedStateControllerAddress​

Removes the address stateControllerAddress from the list of identities that constitute the state controller.

It can only be invoked by the chain owner.

Parameters​

NameTypeOptionalDescription
stateControllerAddress[u8; 32]NoThe address to remove from the set of allowed state controllers

Returns​

None

delegateChainOwnership​

Sets the Agent ID ownerAgentID as the new owner for the chain. This change will only be effective once claimChainOwnership is called by ownerAgentID.

It can only be invoked by the chain owner.

Parameters​

NameTypeOptionalDescription
ownerAgentID[u8; 32]NoThe Agent ID of the next chain owner

Returns​

None

claimChainOwnership​

Claims the ownership of the chain if the caller matches the identity set in delegateChainOwnership.

Parameters​

None

Returns​

None

setFeePolicy​

Sets the fee policy for the chain. It can only be invoked by the chain owner.

Parameters​

NameTypeOptionalDescription
feePolicyFeePolicyNoThe fee policy

Returns​

None

setGasLimits​

Sets the gas limits for the chain. It can only be invoked by the chain owner.

Parameters​

NameTypeOptionalDescription
gasLimitsLimitsNoThe gas limits

Returns​

None

setEVMGasRatio​

Sets the EVM gas ratio for the chain. It can only be invoked by the chain owner.

Parameters​

NameTypeOptionalDescription
evmGasRatioRatio32NoThe EVM gas ratio

Returns​

None

addCandidateNode​

Adds a node to the list of candidates. It can only be invoked by the access node owner (verified via the Certificate field).

Parameters​

NameTypeOptionalDescription
nodePublicKey[u8; 32]NoThe public key of the node to be added
nodeCertificate[u8]NoThe certificate is a signed binary containing both the node public key and their L1 address
nodeAccessAPIstringNoThe API base URL for the node
isCommitteeboolNoWhether the candidate node is being added to be part of the committee or
just an access node

Returns​

None

revokeAccessNode​

Removes a node from the list of candidates. It can only be invoked by the access node owner (verified via the Certificate field).

Parameters​

NameTypeOptionalDescription
nodePublicKey[u8; 32]NoThe public key of the node to be removed
certificate[u8]NoThe certificate of the node to be removed

Returns​

None

changeAccessNodes​

Iterates through the given map of actions and applies them. It can only be invoked by the chain owner.

Parameters​

NameTypeOptionalDescription
accessNodes[]lo.Tuple2[[u8; 32], byte]NoMap of public key => byte):
The list of actions to perform. Each byte value can be one of the following:
  • 0: Remove the access node from the access nodes list.
  • 1: Accept a candidate node and add it to the list of access nodes.
  • 2: Drop an access node from the access node and candidate lists. |

Returns​

None

startMaintenance​

Starts the chain maintenance mode, meaning no further requests will be processed except calls to the governance contract.

It can only be invoked by the chain owner.

Parameters​

None

Returns​

None

stopMaintenance​

Stops the maintenance mode.

It can only be invoked by the chain owner.

Parameters​

None

Returns​

None

setPayoutAgentID​

setPayoutAgentID sets the payout AgentID. The default AgentID is the chain owner. Transaction fee will be taken to ensure the common account has minimum storage deposit which is in base token. The rest of transaction fee will be transferred to payout AgentID.

Parameters​

NameTypeOptionalDescription
payoutAgentID[u8; 32]NoThe payout AgentID

Returns​

None


Views​

getAllowedStateControllerAddresses​

Returns the list of allowed state controllers.

Parameters​

None

Returns​

NameTypeDescription
stateControllerAddresses[[u8; 32]]The list of allowed state controllers

getChainOwner​

Returns the AgentID of the chain owner.

Parameters​

None

Returns​

NameTypeDescription
chainOwnerAgentID[u8; 32]The chain owner agent ID

getChainInfo​

Returns information about the chain.

Parameters​

None

Returns​

NameTypeDescription
chainInfoChainInfoThe chain info

getFeePolicy​

Returns the gas fee policy.

Parameters​

None

Returns​

NameTypeDescription
feePolicyFeePolicyThe gas fee policy

getGasLimits​

Returns the gas limits.

Parameters​

None

Returns​

NameTypeDescription
gasLimitsLimitsThe gas limits

getEVMGasRatio​

Returns the EVM gas ratio.

Parameters​

None

Returns​

NameTypeDescription
evmGasRatioRatio32The EVM gas ratio

getChainNodes​

Returns the current access nodes and candidates.

Parameters​

None

Returns​

NameTypeDescription
accessNodes[[u8; 32]]The access node keys
candidatesAccessNodeInfoMap
of public key => AccessNodeInfo: The candidates info

getMaintenanceStatus​

Returns whether the chain is undergoing maintenance.

Parameters​

None

Returns​

NameTypeDescription
isMaintenanceboolIs maintenance active

getPayoutAgentID​

Returns the payout AgentID.

Parameters​

None

Returns​

NameTypeDescription
payoutAgentID[u8; 32]The payout agent ID

getMetadata​

Returns the metadata.

Parameters​

None

Returns​

NameTypeDescription
publicURLstringThe public URL
metadataPublicChainMetadataThe metadata