Skip to main content
Version: Next

Law Stone

Overview

The okp4-law-stone smart contract aims to provide GaaS (i.e. Governance as a Service) in any Cosmos blockchains using the CosmWasm framework and the Logic OKP4 module.

This contract is built around a Prolog program describing the law by rules and facts. The law stone is immutable, this means it can only be questioned, there are no update mechanisms.

The okp4-law-stone responsibility is to guarantee the availability of its rules in order to question them, but not to ensure the rules application.

To ensure reliability over time, the associated Prolog program is stored and pinned in a okp4-objectarium contract. Moreover, all the eventual loaded files must be stored in a okp4-objectarium contract as well, allowing the contract to pin them.

To be able to free the underlying resources (i.e. objects in okp4-objectarium) if not used anymore, the contract admin can break the stone.

➡️ Checkout the examples for usage information.

InstantiateMsg

Instantiate message

parameterdescription
program_(Required.) _ Binary. The Prolog program carrying law rules and facts.
storage_address_(Required.) _ string. The okp4-objectarium contract address on which to store the law program.

ExecuteMsg

Execute messages

ExecuteMsg::BreakStone

Break the stone making this contract unusable, by clearing all the related resources: - Unpin all the pinned objects on okp4-objectarium contracts, if any. - Forget the main program (i.e. or at least unpin it). Only the contract admin is authorized to break it, if any. If already broken, this is a no-op.

literal
"break_stone"

QueryMsg

Query messages

QueryMsg::Ask

Submits a Prolog query string to the Logic module, evaluating it against the law program associated with this contract.

If the law stone is broken the query returns a response with the error error(system_error(broken_law_stone),root) set in the answer field.

parameterdescription
ask_(Required.) _ object.
ask.query_(Required.) _ string.

QueryMsg::Program

Retrieves the location metadata of the law program bound to this contract.

This includes the contract address of the objectarium and the program object ID, where the law program's code can be accessed.

literal
"program"

QueryMsg::ProgramCode

Fetches the raw code of the law program tied to this contract.

If the law stone is broken, the query may fail if the program is no longer available in the Objectarium.

literal
"program_code"

Responses

ask

propertydescription
answerAnswer|null.
gas_used_(Required.) _ integer.
height_(Required.) _ integer.
user_outputstring|null.

program

ProgramResponse carry elements to locate the program in a okp4-objectarium contract.

propertydescription
object_id_(Required.) _ string. The program object id in the okp4-objectarium contract.
storage_address_(Required.) _ string. The okp4-objectarium contract address on which the law program is stored.

program_code

Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.

This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>. See also <https://github.com/CosmWasm/cosmwasm/blob/main/docs/MESSAGE_TYPES.md>.

type
string.

Definitions

Answer

propertydescription
has_more_(Required.) _ boolean.
results_(Required.) _ Array<Result>.
variables_(Required.) _ Array<string>.

Binary

A string containing Base64-encoded data.

type
string.

Result

propertydescription
errorstring|null.
substitutions_(Required.) _ Array<Substitution>.

Substitution

propertydescription
expression_(Required.) _ string.
variable_(Required.) _ string.

Rendered by Fadroma (@fadroma/schema 1.1.0) from okp4-law-stone.json (5d0e1a8382219324)