Skip to content
Open
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
196 changes: 196 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# SEQICO Smart Contract Deployment

SEQICO is a Hardhat-based project for deploying smart contracts for an ICO (Initial Coin Offering) and ERC20 token on Ethereum and compatible networks. The project contains SEQICO.sol (ICO contract) and SEQToken.sol (ERC20 token contract) with deployment scripts for different configurations.

**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**

## Working Effectively

### Bootstrap, Build, and Test the Repository:

```bash
# Install dependencies (required first step)
npm install
# TIMING: Takes 10-15 seconds. Set timeout to 60+ seconds if using --force flag.

# Compile smart contracts
npx hardhat compile
# TIMING: Takes 2-3 seconds for clean compile. NEVER CANCEL.

# Run tests (currently no tests defined, but validates setup)
npx hardhat test
# TIMING: Takes 1-2 seconds. Returns "0 passing (1ms)".

# Alternative commands using npm scripts:
npm run compile # Same as npx hardhat compile
npm run test # Same as npx hardhat test
```

### Deploy Smart Contracts:

```bash
# Deploy with main script (local network)
npx hardhat run scripts/deploy.js --network hardhat
# TIMING: Takes 1-2 seconds. NEVER CANCEL.

# Deploy with alternative script (local network)
npx hardhat run scripts/deploy-DE.js --network hardhat
# TIMING: Takes 1-2 seconds. NEVER CANCEL.

# Deploy using npm scripts:
npm run deploy # Uses scripts/deploy.js
npm run deploy-de # Uses scripts/deploy-DE.js

# For actual networks (requires environment variables):
npx hardhat run scripts/deploy.js --network sepolia
npx hardhat run scripts/deploy.js --network mainnet
npx hardhat run scripts/deploy.js --network polygon
npx hardhat run scripts/deploy.js --network bsc
```

### Code Quality and Validation:

```bash
# Check code formatting (will show style issues)
npx prettier --check .
# TIMING: Takes 1-2 seconds.

# Format code automatically
npx prettier --write .
# TIMING: Takes 1-2 seconds.

# Solidity linting (requires .solhint.json config file)
npx solhint 'contracts/**/*.sol'
# TIMING: Takes 1-2 seconds. Will fail without config file.
```

## Validation

### Manual Testing Scenarios:

- **ALWAYS build and compile before making changes:** Run `npx hardhat compile` to ensure no syntax errors.
- **ALWAYS test deployment locally:** Run `npx hardhat run scripts/deploy.js --network hardhat` to validate deployment logic.
- **Verify contract functionality:** Check that SEQICO contract can receive the SEQ token address and that token balances are correctly distributed (10% owner, 90% ICO contract).
- **Environment setup validation:** For actual network deployment, ensure you have proper `PRIVATE_KEY`, `INFURA_API_KEY`, and network-specific RPC URLs configured.

### Critical Validation Steps:

1. Contracts must compile without errors
2. Deployment scripts must execute successfully on local network
3. Token distribution must be correct: 50,000 SEQ to owner, 450,000 SEQ to ICO contract
4. ICO contract must be properly updated with the real SEQ token address

## Environment Variables Required for Network Deployment

For deployment to actual networks, configure these environment variables:

- `PRIVATE_KEY`: Your wallet private key (without 0x prefix)
- `INFURA_API_KEY`: Your Infura project API key
- `ETHERSCAN_API_KEY`: For contract verification (optional)
- `SEPOLIA_RPC_URL`: Custom Sepolia RPC (optional, defaults to Infura)
- `MAINNET_RPC_URL`: Custom mainnet RPC (optional, defaults to Infura)
- `POLYGON_RPC_URL`: Custom Polygon RPC (optional, defaults to Infura)
- `BSC_RPC_URL`: Custom BSC RPC (optional, defaults to public endpoint)

## Timeout Guidelines

- **npm install**: Set timeout to 120+ seconds. NEVER CANCEL during dependency resolution.
- **npx hardhat compile**: Set timeout to 60+ seconds. Usually completes in 2-3 seconds but may take longer on first run.
- **Deployment scripts**: Set timeout to 60+ seconds. Usually completes in 1-2 seconds locally.
- **Network operations**: Set timeout to 300+ seconds for actual network deployments as they depend on network congestion.

## Common Tasks

### Repository Structure:

```
├── .github/
│ └── workflows/ci-cd.yml # GitHub Actions CI/CD pipeline
├── contracts/
│ ├── SEQICO.sol # Main ICO contract
│ └── SEQToken.sol # ERC20 token contract
├── scripts/
│ ├── deploy.js # Main deployment script
│ └── deploy-DE.js # Alternative deployment script
├── hardhat.config.js # Hardhat configuration
├── package.json # Dependencies and npm scripts
└── README.md # Project documentation
```

### Key Files Summary:

#### contracts/SEQICO.sol

- ICO contract that allows purchasing SEQ tokens with ETH, USDT, or USDC
- Owner-only functions for token management and fund withdrawal
- Configurable pricing for each payment method

#### contracts/SEQToken.sol

- Standard ERC20 token with 18 decimals
- Total supply: 500,000 SEQ tokens
- Distribution: 10% to owner, 90% to ICO contract

#### scripts/deploy.js & scripts/deploy-DE.js

- Both scripts deploy the same contracts with identical functionality
- Deploy ICO contract first with dummy token address
- Deploy SEQ token with proper distribution
- Update ICO contract with real token address
- Print final balances for verification

### Dependencies and Versions:

- **Hardhat**: 2.19.5 (compatible version, do not upgrade to 3.x)
- **OpenZeppelin Contracts**: 5.4.0 (requires initialOwner parameter in constructors)
- **Node.js**: Project works with Node.js 20.x (Hardhat warning can be ignored)

### CI/CD Pipeline:

The `.github/workflows/ci-cd.yml` defines a 3-stage pipeline:

1. **Build**: Install dependencies and compile contracts
2. **Test**: Run test suite (currently empty but validates setup)
3. **Deploy**: Deploy to mainnet (requires secrets configuration)

### Troubleshooting:

#### Common Issues:

1. **"Cannot read properties of null"** during network deployment: Missing PRIVATE_KEY environment variable
2. **"Invalid config" errors**: Hardhat version compatibility issues (use 2.x, not 3.x)
3. **"No arguments passed to base constructor"**: OpenZeppelin v5 requires initialOwner parameter
4. **Prettier formatting warnings**: Expected and can be auto-fixed with `npx prettier --write .`

#### Version Compatibility:

- This project requires Hardhat 2.x and @nomicfoundation/hardhat-toolbox 2.x
- OpenZeppelin Contracts 5.x requires Ownable(initialOwner) constructor syntax
- Scripts use CommonJS require() syntax, not ES6 imports

### Quick Reference Commands:

```bash
# Setup and build
npm install && npx hardhat compile

# Local deployment test
npx hardhat run scripts/deploy.js --network hardhat

# Code formatting
npx prettier --write .

# Available networks
npx hardhat --help
```

## Project Context

This is a production-ready smart contract deployment project for the SEQICO token sale. The contracts implement:

- **Multi-currency support**: Accepts ETH, USDT, and USDC for token purchases
- **Automatic pricing**: Configurable exchange rates for each currency
- **Security features**: Owner-only functions, automatic ETH refunds for overpayments
- **Token distribution**: Predefined allocation between owner and ICO contract

Always test changes on local network before attempting mainnet deployment.
72 changes: 36 additions & 36 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,59 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
Comment on lines +18 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Upgrade deprecated GitHub Actions to keep CI/CD runnable.

actions/checkout@v3 and actions/setup-node@v3 now target the retired Node 16 runtime, so these steps fail on current GitHub-hosted runners (see actionlint output). Bump them to the v4 releases so the pipeline executes again.

-      - name: Checkout code
-        uses: actions/checkout@v3
+      - name: Checkout code
+        uses: actions/checkout@v4
@@
-      - name: Set up Node.js
-        uses: actions/setup-node@v3
+      - name: Set up Node.js
+        uses: actions/setup-node@v4

Apply the same replacements in the test and deploy jobs.

Also applies to: 38-44, 58-64

🧰 Tools
🪛 actionlint (1.7.7)

19-19: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


22-22: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
.github/workflows/ci-cd.yml lines 18-24 (and similar occurrences at 38-44,
58-64): the workflow uses deprecated action versions actions/checkout@v3 and
actions/setup-node@v3 which target retired Node 16; update these to the v4
releases (actions/checkout@v4 and actions/setup-node@v4) in the listed jobs
(checkout and setup-node steps in the main, test, and deploy jobs) so the CI
uses supported Node runtime on GitHub-hosted runners; ensure the node-version
input remains correct (e.g., 18) and run a local linter or actionlint to confirm
no other deprecated references remain.


- name: Install dependencies
run: npm install
- name: Install dependencies
run: npm install

- name: Compile contracts
run: npx hardhat compile
- name: Compile contracts
run: npx hardhat compile

test:
name: Run Tests
runs-on: ubuntu-latest
needs: build # Ensures tests run after build stage

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm install
- name: Install dependencies
run: npm install

- name: Run tests
run: npx hardhat test
- name: Run tests
run: npx hardhat test

deploy:
name: Deploy Contracts
runs-on: ubuntu-latest
needs: test # Ensures deployment runs after tests pass

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm install

- name: Deploy contracts
run: npx hardhat run scripts/deploy.js --network mainnet
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm install

- name: Deploy contracts
run: npx hardhat run scripts/deploy.js --network mainnet
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,55 @@ A Hardhat project for deploying the SEQICO ICO smart contract and SEQ token.
## 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

## Features

### SEQICO Contract

- Buy SEQ tokens with ETH, USDT, or USDC
- Configurable pricing for each payment method
- Owner-only functions for token management and fund withdrawal
- Automatic ETH refunds for overpayments
- Event logging for all purchases

### SEQToken Contract

- Standard ERC20 token
- Initial distribution: 10% to owner, 90% to ICO contract
- 500,000 total supply

## Setup

1. Install dependencies:

```bash
npm install
```

2. Compile contracts:

```bash
npx hardhat compile
```

3. Deploy contracts:

```bash
# Deploy with main script
npx hardhat run scripts/deploy.js

# Deploy with alternative script
# Deploy with alternative script
npx hardhat run scripts/deploy-DE.js
```

## Contract Functions

### SEQICO Contract

- `buyWithETH(uint256 tokenAmount)`: Purchase tokens with ETH
- `buyWithUSDT(uint256 tokenAmount)`: Purchase tokens with USDT
- `buyWithUSDC(uint256 tokenAmount)`: Purchase tokens with USDC
Expand All @@ -57,6 +64,7 @@ npx hardhat run scripts/deploy-DE.js
## Configuration

The deployment scripts include configurable parameters:

- Owner address
- USDT/USDC contract addresses
- Token pricing for ETH, USDT, and USDC
Expand Down
2 changes: 1 addition & 1 deletion contracts/SEQICO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract SEQICO is Ownable {
uint256 _pricePerTokenETH,
uint256 _pricePerTokenUSDT,
uint256 _pricePerTokenUSDC
) {
) Ownable(msg.sender) {
seqToken = IERC20(_seqToken);
usdt = IERC20(_usdt);
usdc = IERC20(_usdc);
Expand Down
5 changes: 2 additions & 3 deletions contracts/SEQToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ contract SEQToken is ERC20, Ownable {
uint256 totalSupply,
address owner,
address icoContract
) ERC20("SEQ Token", "SEQ") {
) ERC20("SEQ Token", "SEQ") Ownable(owner) {
// Mint 10% to owner, 90% to ICO contract
uint256 ownerAmount = (totalSupply * 10) / 100;
uint256 icoAmount = totalSupply - ownerAmount;

_mint(owner, ownerAmount);
_mint(icoContract, icoAmount);

// Transfer ownership to the specified owner
_transferOwnership(owner);
// Owner is already set in the Ownable constructor
}
}
Loading
Loading