Skip to content
/ Safe Public

πŸ” Safe - A decentralized escrow contract for secure milestone-based project payments. This smart contract facilitates transparent and fair fund management using ERC20/TRC20 tokens, ensuring safe transactions between clients and executors. πŸš€

License

Notifications You must be signed in to change notification settings

Kolot-lu/Safe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Safe

(!This project is currently under development and testing!)

Overview

Safe.kolot.lu is a decentralized escrow contract for secure milestone-based project payments. It facilitates secure transactions between clients and executors with transparent and fair fund management using ERC20/TRC20 tokens.

Features

  • Decentralized Escrow: Securely manage payments between clients and executors.
  • Milestone-Based Payments: Break down project payments into milestones.
  • Platform Fees: Deduct platform fees from project budgets.
  • Cancellation and Refunds: Allow project cancellation and client refunds.
  • Upgradeable Contracts: Utilize OpenZeppelin's upgradeable contracts.

Smart Contracts

  • Safe.sol: The main contract handling project creation, milestone payments, and cancellations.
  • TestERC20.sol: A mock ERC20 token used for testing.

Project Structure

.
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ contracts
β”‚   β”œβ”€β”€ Safe.sol
β”‚   └── ...
β”œβ”€β”€ hardhat.config.ts
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ scripts
β”‚   β”œβ”€β”€ deploy.ts
β”‚   └── ...
β”œβ”€β”€ test
β”‚   β”œβ”€β”€ utils.ts
β”‚   └── safe
β”‚       β”œβ”€β”€ 1_deployment.test.ts
β”‚       β”œβ”€β”€ 2_projectCreation.test.ts
β”‚       └── ...
└── tsconfig.json

Getting Started

Prerequisites

  • Node.js
  • npm or yarn
  • Hardhat
  • An Ethereum wallet with testnet or mainnet access

Installation

  1. Clone the repository:
git clone https://github.com/Kolot-lu/Safe.git
cd Safe
  1. Install dependencies:
npm install
# or
yarn install
  1. Create a .env file in the root directory and add the following variables:
SEPOLIA_URL=https://sepolia.infura.io/v3/YOUR_INFURA_PROJECT_ID
PRIVATE_KEY=your_private_key
TRON_SHASTA_URL=https://api.shasta.trongrid.io
TRON_PRIVATE_KEY=your_tron_private_key

Compiling Contracts

Compile the smart contracts using Hardhat:

npx hardhat compile

Running Tests

Run the tests to ensure everything is working correctly:

npx hardhat test

Deployment

Deploy to Local Network

To deploy the contracts to a local Hardhat network:

npx hardhat node
npx hardhat run scripts/deploy.ts --network localhost

Deploy to Testnet/Mainnet

To deploy the contracts to a testnet (e.g., Sepolia) or mainnet:

npx hardhat run scripts/deploy.ts --network sepolia
# or
npx hardhat run scripts/deploy.ts --network mainnet

Usage

Creating a Project

Use the createProject function to create a new project with specified milestones and platform fee.

function createProject(
    address _executor,
    uint256 _totalAmount,
    uint256[] memory _milestoneAmounts,
    uint256 _platformFeePercent,
    IERC20 _token
) public

Funding a Project

Use the fundProject function to fund a previously created project.

function fundProject(uint256 _projectId) public

Confirming a Milestone

Use the confirmMilestone function to confirm the completion of a milestone and release funds to the executor.

function confirmMilestone(uint256 _projectId) public

Cancelling a Project

Use the cancelProject function to cancel a project and refund the client.

function cancelProject(uint256 _projectId) public

Withdrawing Platform Funds

The owner can withdraw accumulated platform fees using the withdrawPlatformFunds function.

function withdrawPlatformFunds(IERC20 _token) public onlyOwner

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • OpenZeppelin for their excellent library of secure smart contract components.
  • Hardhat for providing a robust development environment for Ethereum software.

About

πŸ” Safe - A decentralized escrow contract for secure milestone-based project payments. This smart contract facilitates transparent and fair fund management using ERC20/TRC20 tokens, ensuring safe transactions between clients and executors. πŸš€

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published