tokenomics
Last updated: 2024-09-27 10:47:33.585680 File source: link on GitLab
tokenomics
Table of Contents
Specification
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.
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.
./Sequences/: Contains the sequence diagram for the tokenomics package
Class Diagram
Source File
Rendered from source file
Functionality
Note: the functionality of Tokenomics is being currently developed. See the proposed section for the suggested design of interfaces and methods.
Data Types
Note: the functionality of DMS is being currently developed. See the proposed section for the suggested data types.
Testing
Unit Tests
TBD
Functional Tests
To be determined (TBD
).
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.
Executes settlement procedures.
Marks the contract as settled.
Notifies both nodes (n1 and n2) about the settlement.
Updates the contract details in the central database.
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).
pricing (PricingMethod): Defines the method used to determine the pricing for the deposit (not fully implemented in this function).
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.
Data types 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.
References
Last updated