Skip to content

Commit

Permalink
Merge pull request #56 from TogetherCrew/add-arbitrum
Browse files Browse the repository at this point in the history
Add arbitrum
  • Loading branch information
Behzad-rabiei authored Dec 3, 2024
2 parents 142bc66 + c89ccd7 commit 57a7d1f
Show file tree
Hide file tree
Showing 7 changed files with 90,157 additions and 54 deletions.
82 changes: 68 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# **Engagement Contract**

## **Overview**

The **Engagement Contract** is a blockchain-based solution for communities to manage reputation and engagement through token issuance and scoring mechanisms. It allows communities to:

- **Issue unique tokens** for their ecosystem.
- **Mint tokens** for individual users based on their activities.
- **Calculate and retrieve reputation scores** for community members using the **OCI (On-Chain Identity) platform**.
Expand All @@ -11,15 +13,18 @@ This project is built with Solidity, Hardhat, and OpenZeppelin libraries, ensuri

## **Contract Addresses**

| Address | Network |
|-------------------------------------------------------------------------------------------------|--------------------------|
| N/A | Sepolia |
| https://sepolia-optimism.etherscan.io/address/0xd826769f1844cc83a16923d2aef8a479e62da732 | Optimisim Sepolia |
| https://sepolia.basescan.org/address/0xCc80586fd99f6804013eA2D43169fc60e466D354 | Base Sepolia |
| Address | Network |
| ---------------------------------------------------------------------------------------- | ----------------- |
| N/A | Sepolia |
| https://sepolia-optimism.etherscan.io/address/0xd826769f1844cc83a16923d2aef8a479e62da732 | Optimisim Sepolia |
| https://sepolia.basescan.org/address/0xCc80586fd99f6804013eA2D43169fc60e466D354 | Base Sepolia |
| https://arbiscan.io/address/0x89aDc2E7561914884c47a2F5447ac5052e6770b1#code | Arbitrum One |


---

## **Features**

- **Token Management**:
- Issue new tokens unique to the community.
- Mint tokens for users with checks to prevent duplicate mints.
Expand All @@ -36,6 +41,7 @@ This project is built with Solidity, Hardhat, and OpenZeppelin libraries, ensuri
---

## **Tech Stack**

- **Smart Contracts**:
- **Solidity**: Core language for smart contract development.
- **OpenZeppelin**: Secure and reusable contract components.
Expand All @@ -53,12 +59,14 @@ This project is built with Solidity, Hardhat, and OpenZeppelin libraries, ensuri
## **Installation**

1. **Clone the Repository**:

```bash
git clone https://github.com/your-username/engagement.git
cd engagement
```

2. **Install Dependencies**:

```bash
npm install
```
Expand All @@ -74,47 +82,91 @@ This project is built with Solidity, Hardhat, and OpenZeppelin libraries, ensuri
## **Usage**

### **Compile Contracts**

Run the following command to compile the contracts:

```bash
npm run compile
```

### **Run Tests**

Execute the test suite to ensure everything is working as expected:

```bash
npm run test
```

### **Deploy Contracts**
To deploy the contracts on a local Hardhat network:
1. Start a local Hardhat node:
```bash
npx hardhat node
```
2. Deploy the contracts:
```bash
npm run deploy:localhost
```

Before deploying, ensure that previous deployment files are removed to prevent conflicts:

- **Remove the directory**: `ignition/deployments/chain-{chainId}` (replace `{chainId}` with the ID of the chain you're deploying to).

### Deploying to Localhost

1. **Start the Hardhat local node**:

- `npx hardhat node`

- **Deploy contracts to localhost**:

1. `npx hardhat run ./scripts/deploys/deploy.ts --network localhost`

### Deploying to a Network

1. **Set up environment variables**:

- **Private Key**: Set your wallet's private key as `PRIVATE_KEY`.
- **Block Explorer API Key**: Set your block explorer API key (e.g., Etherscan API key) for contract verification.

Use Hardhat's `vars` command to set and get environment variables:

- `npx hardhat vars set PRIVATE_KEY
npx hardhat vars get PRIVATE_KEY`
- **Update Hardhat configuration**:

- In your `hardhat.config.js` or `hardhat.config.ts` file:
- **Add network configuration** under `networks` with the appropriate settings (e.g., RPC URL, accounts).
- **Configure Etherscan** for contract verification by adding your API key under `etherscan`.

- **Create a deployment script**:

- Place your deployment script in the `scripts/deploys/` directory.

- **Deploy contracts to the network**:

`npx hardhat run ./scripts/deploys/{scriptname}.ts --network {networkname}`

- Replace `{scriptname}` with your deployment script name.
- Replace `{networkname}` with the network name as defined in your `hardhat.config`.

### **Check Coverage**

Analyze the test coverage for your contracts:

```bash
npm run coverage
```

### **Lint and Format Code**

Lint the project for issues:

```bash
npm run lint
```

Format the project files:

```bash
npm run format
```

---

## **Folder Structure**

```plaintext
.
├── contracts/ # Solidity contracts
Expand All @@ -137,6 +189,7 @@ npm run format
## **Contributing**

Contributions are welcome! Please follow these steps:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-name`).
3. Commit your changes (`git commit -m "Add feature-name"`).
Expand All @@ -146,6 +199,7 @@ Contributions are welcome! Please follow these steps:
---

## **Acknowledgments**

- **OpenZeppelin**: For providing secure and reusable smart contract components.
- **Hardhat Team**: For building a robust Ethereum development environment.
- **OCI Platform**: For enabling seamless identity and reputation management.
Expand Down
86 changes: 46 additions & 40 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,66 @@
import type { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox-viem";
import { vars } from "hardhat/config";
import {generatePrivateKey} from "viem/accounts"
import { generatePrivateKey } from "viem/accounts";

const ALCHEMY_SEPOLIA_ENDPOINT = vars.get("ALCHEMY_SEPOLIA_ENDPOINT", "");
const PRIVATE_KEY = vars.has("PRIVATE_KEY")
? vars.get("PRIVATE_KEY")
: generatePrivateKey();
? vars.get("PRIVATE_KEY")
: generatePrivateKey();

const ETHERSCAN_API_KEY = vars.get("ETHERSCAN_API_KEY", "");

const OPTIMISM_ETHERSCAN_API_KEY = vars.has("OPTIMISM_ETHERSCAN_API_KEY")
? vars.get("OPTIMISM_ETHERSCAN_API_KEY")
: "";

const BASESCAN_API_KEY = vars.has("BASESCAN_API_KEY")
? vars.get("BASESCAN_API_KEY")
: "";

const OPTIMISM_ETHERSCAN_API_KEY = vars.has("OPTIMISM_ETHERSCAN_API_KEY")
? vars.get("OPTIMISM_ETHERSCAN_API_KEY")
: "";
const ARBISCAN_API_KEY = vars.has("ARBISCAN_API_KEY")
? vars.get("ARBISCAN_API_KEY")
: "";
const config: HardhatUserConfig = {
solidity: "0.8.26",
networks: {
sepolia: {
url: ALCHEMY_SEPOLIA_ENDPOINT,
accounts: [PRIVATE_KEY],
},
optimismSepolia: {
chainId: 11155420,
accounts: [PRIVATE_KEY],
url: "https://sepolia.optimism.io",
gasMultiplier: 1.2,
},
baseSepolia: {
solidity: "0.8.26",
networks: {
sepolia: {
url: ALCHEMY_SEPOLIA_ENDPOINT,
accounts: [PRIVATE_KEY],
},
optimismSepolia: {
chainId: 11155420,
accounts: [PRIVATE_KEY],
url: "https://sepolia.optimism.io",
gasMultiplier: 1.2,
},
baseSepolia: {
chainId: 84532,
accounts: [PRIVATE_KEY],
url: "https://sepolia.base.org/",
gasMultiplier: 1.3,
},
},
etherscan: {
apiKey: {
sepolia: ETHERSCAN_API_KEY,
optimismSepolia: OPTIMISM_ETHERSCAN_API_KEY,
baseSepolia: BASESCAN_API_KEY
},
customChains: [
{
network: "optimismSepolia",
chainId: 11155420,
urls: {
apiURL: "https://api-sepolia-optimistic.etherscan.io/api",
browserURL: "https://sepolia-optimism.etherscan.io/",
},
},
],
},
arbitrum: {
chainId: 42161,
accounts: [PRIVATE_KEY],
url: "https://arb1.arbitrum.io/rpc",
},
},
etherscan: {
apiKey: {
sepolia: ETHERSCAN_API_KEY,
optimismSepolia: OPTIMISM_ETHERSCAN_API_KEY,
baseSepolia: BASESCAN_API_KEY,
arbitrumOne: ARBISCAN_API_KEY,
},
customChains: [
{
network: "optimismSepolia",
chainId: 11155420,
urls: {
apiURL: "https://api-sepolia-optimistic.etherscan.io/api",
browserURL: "https://sepolia-optimism.etherscan.io/",
},
},
],
},
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../build-info/4e58f17c75b86363e11bf0ecd1dbfa6a.json"
}
Loading

0 comments on commit 57a7d1f

Please sign in to comment.