Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 107 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,134 @@
## Foundry
# HR_Project_Web3Bridge

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
This repository contains the smart contracts and related scripts for the HR_Project_Web3Bridge, a blockchain-based solution for managing organizations and contracts. The project leverages [Foundry](https://book.getfoundry.sh/) for development, testing, and deployment of Solidity smart contracts.

Foundry consists of:
## Deployed Contracts (Sepolia Network)

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
- **OrganizationFactory**: [0xe1db6db5f799feeb969088ac1ec7072b295a55a0](https://sepolia-blockscout.lisk.com/address/0xe1db6db5f799feeb969088ac1ec7072b295a55a0)
- **OrganizationContract**: [0xe90d6a043c34ab9c03f541e99c21dbe48d14e92b](https://sepolia-blockscout.lisk.com/address/0xe90d6a043c34ab9c03f541e99c21dbe48d14e92b)

## Documentation
## Table of Contents

https://book.getfoundry.sh/
- [Overview](#overview)
- [Project Structure](#project-structure)
- [Installation](#installation)
- [Usage](#usage)
- [Smart Contracts](#smart-contracts)
- [Testing](#testing)
- [Deployment](#deployment)
- [Contributing](#contributing)
- [License](#license)

## Usage
## Overview

### Build
HR_Project_Web3Bridge is a decentralized solution that enables organizations to manage their operations on the blockchain. The project consists of multiple smart contracts that handle organization creation, management, and token operations.

```shell
$ forge build
```
### Key Features

- Organization creation and management
- Token management system
- Secure contract interactions
- Full test coverage
- Foundry-based development environment

### Test
## Project Structure

```shell
$ forge test
```
contracts/
├── src/
│ ├── contracts/ # Main contract implementations
│ ├── interfaces/ # Contract interfaces
│ └── libraries/ # Shared libraries and utilities
├── script/ # Deployment scripts
├── test/ # Contract test files
└── lib/ # Dependencies and libraries
```

### Format
## Installation

```shell
$ forge fmt
```
1. **Prerequisites**
- [Foundry](https://book.getfoundry.sh/getting-started/installation.html)
- Git

### Gas Snapshots
2. **Clone the Repository**
```bash
git clone <repository-url>
cd HR_Project_Web3Bridge/contracts
```

```shell
$ forge snapshot
```
3. **Install Dependencies**
```bash
forge install
```

### Anvil
## Usage

```shell
$ anvil
### Compiling Contracts
```bash
forge build
```

### Deploy
### Running Tests
```bash
forge test
```

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
### Deploying Contracts
```bash
forge script script/deploy.s.sol --rpc-url <your-rpc-url> --private-key <your-private-key> --broadcast
```

### Cast
## Smart Contracts

### OrganizationFactory
- Main contract for creating and managing organizations
- Handles organization deployment and registration
- Maintains organization registry

### OrganizationContract
- Implements organization-specific logic
- Manages organization members and roles
- Handles organization-specific operations

```shell
$ cast <subcommand>
### Additional Components
- **IERC20.sol**: Standard ERC20 interface implementation
- **Tokens.sol**: Token management functionality
- **errors.sol**: Custom error definitions
- **structs.sol**: Shared data structures

## Testing

The project includes comprehensive tests for all smart contracts. Test files are located in the `test/` directory:

- OrganizationContract.t.sol
- OrganizationFactory.t.sol
- Token.t.sol

To run specific tests:
```bash
forge test --match-contract OrganizationFactoryTest
```

### Help
## Deployment

The project uses Foundry's deployment system through scripts in the `script/` directory. The main deployment script is `deploy.s.sol`.

```shell
$ forge --help
$ anvil --help
$ cast --help
### Deployment Commands
```bash
# Deploy to local network
forge script script/deploy.s.sol --fork-url http://localhost:8545 --broadcast

# Deploy to testnet
forge script script/deploy.s.sol --rpc-url <testnet-rpc> --private-key <pk> --broadcast --verify
```

### Verification Commands
Verification commands can be found in `verify_command.txt`

## Contributing

1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push to the branch
5. Open a Pull Request
240 changes: 240 additions & 0 deletions broadcast/deploy.s.sol/4202/run-1745498012.json

Large diffs are not rendered by default.

240 changes: 240 additions & 0 deletions broadcast/deploy.s.sol/4202/run-1745498130.json

Large diffs are not rendered by default.

240 changes: 240 additions & 0 deletions broadcast/deploy.s.sol/4202/run-1745498326.json

Large diffs are not rendered by default.

240 changes: 240 additions & 0 deletions broadcast/deploy.s.sol/4202/run-1745498368.json

Large diffs are not rendered by default.

240 changes: 240 additions & 0 deletions broadcast/deploy.s.sol/4202/run-latest.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ src = "src"
out = "out"
libs = ["lib"]
solc = "0.8.28"
via_ir = true
optimizer = true
optimizer_runs = 200

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
forge-std/=lib/forge-std/src/
42 changes: 42 additions & 0 deletions script/deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import "forge-std/Script.sol";
import "forge-std/Vm.sol";
import "forge-std/console.sol";
import {OrganizationFactory} from "../src/contracts/OrganizationFactory.sol";
import {OrganizationContract} from "../src/contracts/OrganizationContract.sol";

contract OrganizationScript is Script {
address public organizationAddress;
address public recipientAddress;
address public tokenAddress;

function setUp() public {
// organizationAddress = vm.envAddress("ORGANIZATION_ADDRESS");
recipientAddress = vm.envAddress("RECIPIENT_ADDRESS");
tokenAddress = vm.envAddress("TOKEN_ADDRESS");
}

function run() public {
vm.startBroadcast();
// Deploy the OrganizationFactory contract
OrganizationFactory organizationFactory = new OrganizationFactory(vm.envAddress("FEE_COLLECTOR_ADDRESS"));
console.log("OrganizationFactory deployed at:", address(organizationFactory));

// Create a new organization
organizationAddress =
organizationFactory.createOrganization("My Organization", "This is a description of my organization.");
console.log("Organization created at:", organizationAddress);

// Add a token to the organization
organizationFactory.addToken("MyToken", tokenAddress);
console.log("Token added:", tokenAddress);

// Create a new recipient
OrganizationContract(organizationAddress).createRecipient(recipientAddress, "John Doe", 1000);
console.log("Recipient created at:", recipientAddress);

vm.stopBroadcast();
}
}
3 changes: 3 additions & 0 deletions script_command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
forge script script/deploy.s.sol:OrganizationScript --chain-id 4202 --rpc-url https://rpc.sepolia-api.lisk.com \
--etherscan-api-key 123 --verifier-url https://sepolia-blockscout.lisk.com/api \
--broadcast --verify --verifier blockscout --account PRIVATE_KEY -vvvv
Loading