What is Value Contract
A Value Contract (VC) is a program executed on a distributed ledger, designed for creating secure, decentralized services and data storage.
Written in C++ and compiled into WebAssembly (Wasm), the VC is deployed on the ledger database, defining data storage schemas and enabling custom services to meet specific database needs.
This system serves as a core component in decentralized ledger system (DLS) systems by ensuring secure execution and interaction with the database.
Key Components
- Compositions: Defines the structure of data models, including strict data schemas and indexes.
- Services: Specifies operations that can be executed within the ledger database, aligning with the custom requirements.
Compiler
The Inery-specific inery-cpp
compiler is used to convert VC code from C++ to WebAssembly (Wasm) and to generate an Application Binary Interface (ABI). This custom compilation process transforms the contract into an efficient, executable format for the ledger database.
- Source Language: C++
- Target Format: WebAssembly (Wasm) and Application Binary Interface (ABI)
Value Contract Files
VCs are constructed using C++ and deployed to the ledger as Wasm and ABI files. The essential file types in a VC include:
- .cpp - C++ source code defining logic, data structure, and actions.
- .hpp - Header file for declaring functions and data types.
- .wasm - WebAssembly binary, containing the compiled code ready for ledger deployment.
- .abi - ABI file, specifying the interface and actions accessible within the ledger database.
C++
In VCs, C++ serves as the foundation language, offering object-oriented, generic, and low-level memory manipulation capabilities crucial for efficient contract execution. By extending the Inery contract class, developers can define:
- Data Structures: Custom schemas for data storage within the ledger.
- Custom Services: Tailored actions that facilitate unique database operations.
These components allow the VC to integrate seamlessly with the ledger’s database infrastructure while maintaining security and flexibility.
WebAssembly (Wasm)
WebAssembly, abbreviated as Wasm, is a binary instruction format compatible with stack-based virtual machines. It enables cross-platform execution by serving as a target compilation language for high-level languages such as C++. The inery-cpp compiler compiles C++ VC code into Wasm and prepares it for deployment on the ledger. Wasm’s lightweight and efficient design makes it ideal for decentralized applications requiring rapid, secure execution.
Application Binary Interface (ABI)
The Application Binary Interface (ABI) defines the rules and structures that enable interaction between the WebAssembly code and the ledger database. It ensures seamless execution of defined actions, allowing custom services to operate within the ledger’s ecosystem. Key features include:
Action Mapping: Establishes functions accessible within the contract. Data Encoding: Converts structured data to compatible formats for the ledger. Execution Rules: Defines permissible actions within the ledger environment, ensuring compatibility and security.
Wasm and ABI files, once deployed, bind directly with the ledger database, ensuring smooth execution and accessibility of defined actions.