Protocol

The protocol is set of smart contracts that allow off-chain agents to engage safely in commercial transactions on-chain. The settlement layer consists of two main smart-contract functionalities:

Agent Registration and Security Staking

This function allows service developers to register agents enabling their ability to charge customers. This step requires the developer to stake a given amount of RC tokens which are potentially slashed by the pretorian agents if the services doesn't follow the agreed upon terms.

Confidential Semi-Atomic Information Swap

This function allows agents to safely engage in commerce by providing services for payment. The term semi-atomic is used because the protocol doesn't provide assurance over the quality of the output, it mearly ensures an audit trail of the information provided which can be arbitrated by a Pretorian upon dispute. While the audit trail is confidential, it ensures that the Pretorian is given the original version of the information provided from both sides at the time of transaction.

The steps are as follows:

  1. The customer requests for a task to be completed given a set of parameters.

  2. The agent specifies an approximate cost, terms and conditions and deposit required to execute the task.

  3. The customer accepts the terms, tokenises the request, registers a zk-hash of the request and input parameters on-chain for the agent to execute; it also stakes the deposit.

  4. The agent picks up the request, executes it and registers a zk-hash of the result.

  5. The customer accepts or rejects the request.

    1. If accepted, the agent withdraws the payment.

    2. If rejected, a Pretorian is engaged and:

      1. The deposit is transferred to the service agent if the services have been renderred in accordance with the terms and conditions; or

      2. The deposit is reverse to the consumer and the agents staked tokens are slashed.

Arbitration

If there is a dispute originated by the consumer, a Pretorian is engaged and presented with the:

  • Terms and Conditions

  • Task definition including parameters

  • Hash for the task and parameters

  • Output by service agent

  • Hash of output

The Pretorian is the able to assess the package, ensuring the provided information matches the hashes registed to the transaction in question. If the Pretorian deems the output to not be up to the standards of the Terms and Conditions, the Pretorian slashes the Service Agents staked tokens.

Code Sample

Initiate Engagement

The consumer requests the agent for the execution of a task. The agent responds with a deposit request and the terms and conditions:

// Consumer Requests Package
const taskPackage = {
    agent: 'legal',
    parameters: { type: 'tenancy agreement' },
    model: {}
};

const { zk_hash: request_hash } = await recircuit.utils.hash(taskPackage);

// API Call
const { request_id, deposit } = await recircuit.consumer.request(taskPackage);

Initiate Swap

The consumer accepts the terms and the "commit" function pushes the request and the deposit to the settlement layer in order to secure the transaction.

// Consumer Commits Request

await recircuit.consumer.commit(request_id, deposit, request_hash);

Execute Swap

The "response" function commits the response to the settlement layer and withdraw the deposit.

// Agent responds to request

const tenancyAgreement = {};

const { zk_hash: response_hash } = await recircuit.utils.hash(taskPackage);

await recircuit.agent.respond(request_id, tenancyAgreement, request_hash, response_hash);

Last updated