Skip to content

Joewizy/Foundry-Revenue-Distribution-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Foundry Revenue Distribution System

Overview

The Revenue Distribution smart contract uses a time-based mechanism to automate the distribution of revenue among community members, stakeholders, and operating costs. Every quarter, it automates revenue distribution using Chainlink Keepers.

Key Features

  • Revenue Deposits: Stakeholders can deposit Ether as revenue into the contract.
  • Automated Quarterly Distribution: Revenue is distributed every quarter using Chainlink Keepers, ensuring smooth automation.
  • Fair Allocation:
    • 60% of revenue is distributed to community members.
    • 30% is distributed to stakeholders.
    • 10% covers operational costs.
  • Lock Period: Stakeholders can only withdraw their revenue after a 30-day lock period.
  • Minimum Deposit: A minimum deposit of 1 ETH is required for stakeholders.
  • Upkeep: Chainlink Keepers are used to automate the distribution process when conditions are met.

Installation

To get started install both Git and Foundry

  • Git: After installation make sure to run git --version to confirm installation if you see a response like git version 2.34.1 then it was successful.

  • Foundry: After installation run forge --version if you see a response like forge 0.2.0 (8549aad 2024-08-19T00:21:29.325298874Z) then it was successful.

Clone the repository

git clone https://github.com/Joewizy/Foundry-Revenue-Distribution-System
cd /Foundry-Revenue-Distribution-System
forge install
forge build

Test

$ forge test

Test Coverage

$ forge coverage

To view detailed test coverage reports for your contracts

Usage

Start a local node

$ anvil

Deploy

By default, your local node will be used here. For it to deploy, it must be running in a separate terminal.

$ make deploy 

Deploy to a Testnet or Mainnet

By default, your local node will be used here. For it to deploy, it must be running in a separate terminal. All this varaibles should be added to your .env file.

  1. Setup your environment variables PRIVATE_KEY , ETHERSCAN_API_KEY and SEPOLIA_RPC_URL.
  • PRIVATE_KEY: Import your metamask private key. It is recommended you use a wallet with no funds or a burner wallet. Learn how to export private key HERE
  • SEPOLIA_RPC_URL: This is URL of the sepolia testnet node you're working with. You can get setup with one for free from Alchemy
  • ETHERSCAN_API_KEY: for verification of your contract on Etherscan. Learn how to get one HERE
  1. Get ETH testnet tokens by heading over to faucets.chain.link and claim some testnet ETH.
  2. Deploy (make deploy = proxy contract and make upgrade = upgradeable contract)
source .env
make deploy ARGS="--network sepolia"

CAST

You can use cast to interact with your deployed smart contract on your terminal

$ cast <contract-address> <function> [params...]

for example cast call to read data on your deployed contract

cast call 0x5FbDB2315678afecb367f032d93F642f64180aa3 "getStakeHoldersAddress()" --private-key [your private key]

cast send sends transactions to the deployed contract

cast send 0x5FbDB2315678afecb367f032d93F642f64180aa3 "depositRevenue()" --value 2ether --private-key [your private key] --rpc-url http://127.0.0.1:8545 --broadcast

Gas Snapshots

You can estimate how much gas things cost by running:

$ forge snapshot

And you'll see an output file called .gas-snapshot

Help

$ forge --help
$ anvil --help
$ cast --help

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published