Skip to content
Draft
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
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Environment Variables for Smart Contract Deployment

# Your private key for the account that will deploy the contracts
# NEVER commit this to version control
PRIVATE_KEY=your_private_key_here

# Infura API key for connecting to Ethereum networks
# Get this from https://infura.io/
INFURA_API_KEY=your_infura_api_key_here

# Network to deploy to (hardhat, mainnet, sepolia, polygon)
NETWORK=hardhat
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy Smart Contracts

on:
push:
branches: [ main ]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Compile contracts
run: npx hardhat compile

- name: Deploy contracts to network
run: npx hardhat run scripts/deploy.js --network ${{ secrets.NETWORK || 'hardhat' }}
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}

- name: Upload deployment artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: deployment-artifacts
path: |
artifacts/
cache/
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ yarn-error.log*
cache/
artifacts/

# Environment variables
.env
.env.local
.env.production

# Coverage reports
coverage/

# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.
49 changes: 39 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# SEQICO Smart Contract Deployment

A Hardhat project for deploying the SEQICO ICO smart contract and SEQ token.
A Hardhat project for deploying the SEQICO ICO smart contract and SEQ token with automated GitHub Actions deployment.

## Overview

This project contains:
- **SEQICO.sol**: The main ICO contract allowing token purchases with ETH, USDT, and USDC
- **SEQToken.sol**: The ERC20 token contract
- **Deployment scripts**: Two deployment scripts with different configurations
- **Deployment scripts**: Automated deployment scripts with deployer information logging
- **GitHub Actions**: Automated deployment pipeline triggered on main branch merges

## Features

Expand All @@ -23,27 +24,55 @@ This project contains:
- Initial distribution: 10% to owner, 90% to ICO contract
- 500,000 total supply

### Automated Deployment
- GitHub Actions workflow triggers on main branch pushes
- Automated contract compilation and deployment
- Secure environment variable handling
- Deployment artifact uploads

## Setup

1. Install dependencies:
```bash
npm install
npm install --legacy-peer-deps
```

2. Configure environment variables:
```bash
cp .env.example .env
# Edit .env with your actual values
```

2. Compile contracts:
3. Compile contracts:
```bash
npx hardhat compile
npm run compile
```

3. Deploy contracts:
4. Deploy contracts:
```bash
# Deploy with main script
npx hardhat run scripts/deploy.js
# Deploy to local Hardhat network
npm run deploy

# Deploy with alternative script
npx hardhat run scripts/deploy-DE.js
# Deploy to specific networks
npm run deploy:sepolia
npm run deploy:mainnet
npm run deploy:polygon
```

## GitHub Actions Deployment

### Required Secrets
Configure these secrets in your GitHub repository:
- `PRIVATE_KEY`: Your deployment account's private key
- `INFURA_API_KEY`: Your Infura project API key
- `NETWORK`: Target network (hardhat, mainnet, sepolia, polygon)

### Workflow Trigger
The deployment workflow automatically triggers when:
- Code is pushed to the `main` branch
- All contracts are compiled and deployed to the specified network
- Deployment artifacts are uploaded for review

## Contract Functions

### SEQICO Contract
Expand Down
19 changes: 18 additions & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
/** @type import('hardhat/config').HardhatUserConfig */
export default {
solidity: "0.8.24"
solidity: "0.8.24",
networks: {
hardhat: {
// Local development network
},
mainnet: {
url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
},
sepolia: {
url: `https://sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
},
polygon: {
url: `https://polygon-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
}
}
};
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
"description": "Deployment",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"compile": "npx hardhat compile",
"deploy": "npx hardhat run scripts/deploy.js",
"deploy:mainnet": "npx hardhat run scripts/deploy.js --network mainnet",
"deploy:sepolia": "npx hardhat run scripts/deploy.js --network sepolia",
"deploy:polygon": "npx hardhat run scripts/deploy.js --network polygon",
"verify": "npx hardhat run scripts/verify-deployment.js",
"verify:mainnet": "npx hardhat run scripts/verify-deployment.js --network mainnet",
"verify:sepolia": "npx hardhat run scripts/verify-deployment.js --network sepolia",
"verify:polygon": "npx hardhat run scripts/verify-deployment.js --network polygon"
},
"keywords": [],
"author": "",
Expand Down
17 changes: 17 additions & 0 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { ethers } from "hardhat";

async function main() {
// Get deployer account
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);

// Log deployer balance
const deployerBalance = await ethers.provider.getBalance(deployer.address);
console.log("Deployer account balance:", ethers.formatEther(deployerBalance), "ETH");

// Replace with your actual owner address
const OWNER = "0x4B958C04701616A0ffF821E9b2db130983c5f3E4";
// USDT and USDC contract addresses (ensure these are correct for your network)
Expand Down Expand Up @@ -44,6 +52,15 @@ async function main() {
const icoBal = await seqToken.balanceOf(ICO);
console.log("Owner balance:", ethers.formatEther(ownerBal));
console.log("ICO balance:", ethers.formatEther(icoBal));

// 5. Save deployment summary
console.log("\n=== Deployment Summary ===");
console.log("Deployer:", deployer.address);
console.log("SEQICO Contract:", ICO);
console.log("SEQToken Contract:", seqTokenAddress);
console.log("Network:", (await ethers.provider.getNetwork()).name);
console.log("Chain ID:", (await ethers.provider.getNetwork()).chainId);
console.log("=========================");
}

main().catch((error) => {
Expand Down
34 changes: 34 additions & 0 deletions scripts/verify-deployment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ethers } from "hardhat";

/**
* Verification script to check deployed contracts
* Usage: npx hardhat run scripts/verify-deployment.js --network <network>
*/
async function main() {
console.log("=== Deployment Verification Script ===");

// Get deployer account
const [deployer] = await ethers.getSigners();
console.log("Verifying with account:", deployer.address);

// Log current balance
const balance = await ethers.provider.getBalance(deployer.address);
console.log("Account balance:", ethers.formatEther(balance), "ETH");

console.log("Network:", (await ethers.provider.getNetwork()).name);
console.log("Chain ID:", (await ethers.provider.getNetwork()).chainId);

// Note: To verify specific contract addresses, you would need to save them during deployment
// and then load them here. This script demonstrates the verification structure.

console.log("\n=== Contract Verification Complete ===");
console.log("To verify specific deployed contracts:");
console.log("1. Save contract addresses during deployment");
console.log("2. Load and verify contract state");
console.log("3. Check contract balances and permissions");
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});