Skip to main content

Claims Key/Value Storage System

Claims in Coinweb

Claims in Coinweb are key/value storage objects that are fundamental to the operation of smart contracts. They are similar to UTXOs in Bitcoin, in that they store value and have specific rules for access. Claims consist of an issuer (owner), a key, a body, and some amount of CWEB (Coinweb's native token).

Structure of a Claim

Claims have a three-level key structure:

  1. Issuer: The creator of the claim, typically a smart contract.
  2. First Key: Often used as the "table name" in the context of the claim.
  3. Second Key: Used as the "key in table", providing an additional level of organization within the claim.

This structure allows a smart contract to have multiple key-value tables, with the table name as the first key and the keys within those tables as the second key.

Operations on Claims

Smart contracts interact with claims through various operations:

  • TakeOp: Allows the issuer of a claim to retrieve the stored CWEB, effectively transferring value into the currently executing transaction.
  • StoreOp: Enables the storage of claims in the database, which can also include CWEB from the current transaction.
  • ReadOp: Permits reading the data of a claim without transferring value.

Queries on Claims

While it is not possible to fetch all claims for a given contract_id in a single query, range queries on the second key are supported. These queries are limited in scope to ensure efficient use of I/O, time, and CPU resources.

Transactions and Claims

A transaction in Coinweb is a list of operations that can include TakeOp, StoreOp, ReadOp, BlockOp, DataOp, and CallOp. Transactions can invoke smart contracts, pass on CWEB, and store or retrieve data as needed. Smart contracts use these transactions to manage their state and interact with other contracts and the blockchain.

Integration with Smart Contracts

Claims are integral to the functioning of smart contracts in Coinweb. They provide a flexible and powerful way to store and manage state, transfer value, and interact with the blockchain. Whether you are building a new smart contract or integrating an existing one, understanding claims is essential for effective development on the Coinweb platform.

For more detailed examples and use cases, refer to the specific documentation on smart contract operations and the data-hasher contract.