Skip to content

dappteacher/onchain-agreements

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Onchain Agreements

Tokenized Agreement Infrastructure for On-Chain Financial Contracts

Onchain Agreements is a modular smart contract system that enables the creation of tokenized financial agreements with governance and profit distribution mechanisms.

The protocol allows operators to deploy independent agreement contracts where participants receive ERC-20 tokens representing their participation rights and governance power.

These agreements can be used for a wide range of financial coordination use cases including investment deals, profit-sharing partnerships, DAO treasury agreements, and structured fundraising mechanisms.

The system is implemented in Solidity and built using the **Foundry development framework.


Key Features

Tokenized Agreements

Each agreement is represented by a smart contract that deploys its own ERC-20 token representing participation or ownership.

Participants holding these tokens can interact with the agreement and participate in governance.


Governance-Controlled Unlocking

Agreements can require a voting quorum before certain actions are executed, such as unlocking funds or enabling profit distribution.

This allows multiple stakeholders to coordinate decisions securely.


Profit Distribution

The protocol supports stablecoin-based profit distribution according to predefined agreement parameters.

Participants can receive profits proportionally based on their token holdings.


Factory Architecture

The protocol uses a factory contract pattern, allowing new agreements to be deployed efficiently while keeping each agreement isolated.

This architecture enables:

  • scalable deployments
  • independent contract logic
  • easier auditing
  • modular governance structures

Protocol Architecture

The system is composed of several main components.

Factory Contract
        │
        │ deploys
        ▼
Agreement Contract
        │
        ├── ERC20 Participation Token
        ├── Governance Voting Mechanism
        ├── Token Lock / Unlock Logic
        └── Profit Distribution System

Each agreement functions as an independent financial contract with configurable parameters.


Smart Contracts

Factory

Responsible for deploying new agreements.

Main responsibilities:

  • create new Agreement contracts
  • configure agreement parameters
  • enforce operator permissions
  • emit deployment events

Agreement

Represents an individual financial agreement between participants.

Key capabilities:

  • deploy ERC-20 participation token
  • manage voting quorum
  • control token locking and unlocking
  • track votes from authorized voters
  • enforce agreement deadlines
  • distribute profits

ERC20Token

Custom ERC-20 token implementation used to represent participant shares within each agreement.

Features include:

  • configurable name and symbol
  • configurable decimals
  • initial supply minted at deployment

Governance Model

The protocol supports a governance structure that includes:

  • operators responsible for creating agreements
  • voters authorized to participate in governance decisions
  • token holders representing agreement participants

Certain actions such as unlocking tokens or adjusting parameters require reaching a minimum quorum of votes.


Security Considerations

Security is an important aspect of the protocol design.

Key protections implemented include:

  • reentrancy protection
  • restricted administrative functions
  • quorum-based governance execution
  • modular contract separation

Before production deployment it is recommended to perform:

  • professional smart contract audit
  • economic attack analysis
  • extensive unit testing

Project Structure

src/
│
├── Agreement.sol
├── Factory.sol
├── ERC20Token.sol
│
├── ERC20/
│   ├── ERC20.sol
│   ├── IERC20.sol
│   └── extensions/
│
├── Role/
│   ├── Governable.sol
│   └── Roles.sol
│
├── security/
│   └── ReentrancyGuard.sol
│
└── utils/
    ├── Context.sol
    ├── Ownable.sol
    └── SafeMath.sol

Development

The project uses the **Foundry toolkit for development, testing, and deployment.

Install Foundry

curl -L https://foundry.paradigm.xyz | bash
foundryup

Build Contracts

forge build

Run Tests

forge test

Deploy Contracts

forge script script/Deploy.s.sol --broadcast

Potential Use Cases

Onchain Agreements can be used to build various decentralized financial coordination systems such as:

  • investment syndicates
  • profit-sharing partnerships
  • startup fundraising agreements
  • DAO treasury allocations
  • tokenized joint ventures

Because each agreement is deployed independently, the protocol supports high flexibility for different financial arrangements.


Future Improvements

Planned enhancements may include:

  • multi-signature governance support
  • snapshot-based voting
  • upgradeable agreement templates
  • gas optimization
  • enhanced profit distribution models
  • protocol analytics tools

Author

Yaghoub Adelzadeh Blockchain Engineer

GitHub https://github.com/dappteacher


License

MIT License


About

Smart contract infrastructure for creating tokenized financial agreements with governance voting and programmable profit distribution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors