tokenomics
Last updated: 2024-11-21 22:06:10.615902 File source: link on GitLab
tokenomics
Table of Contents
Specification
1. Description
This repository contains implementations for managing contracts, proofs, and payments in tokenomics. Initiated within milestone Device Management Service Version 0.5.x, it offers a comprehensive set of interfaces and methods. To implement these functions, we first define key datatypes and interfaces.
2. Structure and Organisation
Here is quick overview of the contents of this directory:
README: Current file which is aimed towards developers who wish to use and modify the package functionality.
Contract.go: Defines the main interface for managing and executing contracts within the tokenomics system.
Proofs.go: Implements the interface and logic for proof handling within the tokenomics framework.
payments.go: Contains the main interface and functions for processing payments in the tokenomics system.
tokenomics.go:: Defines the core functionalities and main interface for the tokenomics package, integrating contracts, proofs, and payments.
Subpackages
./specs/: Directory containing package specifications, including package class diagram.
./private_ledger/: Directory containing implementation of private ledger.
./Sequences/: Contains the sequence diagram for the tokenomics package
3. Class Diagram
Source File
Rendered from source file
4. Functionality
Note: the functionality of Tokenomics is being currently developed. See the proposed section for the suggested design of interfaces and methods.
5. Data Types
Note: the functionality of Tokenomics is being currently developed. See the proposed section for the suggested data types.
6. Testing
Unit Tests
TBD
Functional Tests
To be determined (TBD
).
7. Proposed Functionality / Requirements
List of issues related to the design of the tokenomics package can be found below. These include proposals for modifications to the package or new functionality needed to cover the requirements of other packages.
Interfaces and Methods:
Proposed Contract Interface
NewContract(): Creates new contract
InitiateContractClosure: function initializes and closes a contract between two nodes within the system. It follows the sequence:
Creates a new contract instance.
Populates the contract with job ID and payment details extracted from the provided bid.
Signs and notarizes the contract.
Persists the contract in the contract lists of both nodes (n1 and n2) and the central database.
InitiateContractSettlement: function initiates the settlement process for a specified contract between two nodes (n1 and n2). It executes the following steps:
Updates the contract with the provided verification result.
Handles settlement based on the job status and processes payments.
Notifies both nodes (n1 and n2) about the settlement.
Updates the contract details in the central database.
ProcessContractSettlement: processes the contract settlement based on the pricing method and verification result
Calculates payment based on the pricing method and processes it.
Handles job failure by issuing refunds if required.
Proposed Proof Interface
The InitiateContractApproval(): initiates the contract approval process, starting necessary workflows.
The CreateContractProof(): generates a cryptographic proof for a contract, ensuring transaction integrity.
The SaveProof(contractID, proof string) error: stores the contract proof in a simulated database, maintaining audit trails and historical records.
The VerifyProof(contractID, proof string) (bool, error): verifies the authenticity of a contract proof, ensuring its validity before further processing.
Proposed Payment Interface
Deposit: manages the deposit logic for payments, distinguishing between direct and escrow methods. It ensures that only valid payment types (fiat or crypto) are accepted for escrow payments. This function is crucial for initiating the payment process based on the specified method and type.
Parameters:
contractID (int): Identifier of the contract associated with the payment.
payment (Payment): Struct containing details of the payment, including its method (direct or escrow) and payment type (fiat or crypto).
SettleContract: manages the settlement process for contracts based on job verification results. It calculates the payment amount based on the job's completion percentage and processes payments either directly or via escrow, depending on the contract's payment method (direct or escrow). It also handles scenarios where job verification fails and ensures appropriate actions such as refunds for escrow payments.
FixedJobPricing: It holds pricing details for jobs with fixed payment terms.
PeriodicPricing: It is used for jobs with periodic payment structures. It also includes usage limits to define quotas.
Data types proposed
proposed
proposed tokenomics.Contract: Consists of detailed information regarding an agreement between a requestor and a provider within the network. This data type includes the following fields:
tokenomics.Payment: Consists of details related to a payment transaction between a requestor and a provider, specifying the type, channel, currency, pricing method, and timestamp of the transaction.
tokenomics.FixedJobPricing: Consists of information related to the fixed pricing for a job, detailing the cost and platform fee involved.
tokenomics.PeriodicPricing: Consists of information related to the periodic pricing model, including the cost, period, usage limits, and platform fee.
tokenomics.UsageLimits: Consists of information regarding the resource usage limits or quotas associated with periodic pricing, specifying the maximum allowable usage for various resources.
tokenomics.Authentication: type is designed to handle the authentication details necessary for secure transaction processing within the payment gateway system. This type includes:
Encryption: Specifies the encryption method or protocol used to protect the data involved in the authentication process, ensuring that data is transmitted securely and is kept confidential from unauthorized parties.
ZKProof: Contains the zero-knowledge proof (ZKProof) which allows the verification of the transaction's authenticity without exposing sensitive information. This proof ensures that the transaction is valid while preserving privacy.
OffChain: Represents off-chain data that supports the authentication process. This data includes information not stored directly on the blockchain but is essential for validating and processing transactions securely.
Private_ledger
The private_ledger
sub package provides a DatabaseManager
to manage PostgreSQL databases for contracts database. It allows users to initialize database connections, insert contract data, retrieve contract, and close connections safely.
Features
Database Initialization: Create and manage a connection to a PostgreSQL database.
Contract Retrieval: Fetch all records from a specified table.
Storing Contract: Insert contract records into table.
Connection Management: Close database connections safely.
8. References
Last updated