Skip to content

Commit 2da693e

Browse files
Copilotsonnyquinn24
andcommitted
Create comprehensive copilot instructions for SEQICO smart contract project
Co-authored-by: sonnyquinn24 <227287527+sonnyquinn24@users.noreply.github.com>
1 parent b6ceb05 commit 2da693e

File tree

1 file changed

+192
-0
lines changed

1 file changed

+192
-0
lines changed

.github/copilot-instructions.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# SEQICO Smart Contract Deployment Project
2+
3+
SEQICO is a Hardhat-based Ethereum smart contract project for deploying an ICO (Initial Coin Offering) that allows purchasing SEQ tokens with ETH, USDT, and USDC. The project includes two smart contracts: SEQICO (ICO contract) and SEQToken (ERC20 token).
4+
5+
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.
6+
7+
## Working Effectively
8+
9+
### Bootstrap and Install Dependencies
10+
```bash
11+
# Install dependencies (REQUIRED: use legacy peer deps due to version conflicts)
12+
npm install --legacy-peer-deps
13+
```
14+
15+
**CRITICAL**: Always use `--legacy-peer-deps` flag when installing. Standard `npm install` will fail due to version conflicts between hardhat 3.0.3 and hardhat-toolbox 6.1.0.
16+
17+
### Network Limitations and Compilation Issues
18+
19+
**IMPORTANT**: This environment has network restrictions that prevent downloading the Solidity compiler from binaries.soliditylang.org. The following commands will FAIL:
20+
- `npx hardhat compile` - Cannot download Solidity compiler
21+
- `npx hardhat build` - Cannot download Solidity compiler
22+
- `npx hardhat run scripts/deploy.js` - Requires compilation first
23+
- `npx hardhat test` - Requires compilation first
24+
25+
### Working Commands in Restricted Environment
26+
27+
```bash
28+
# Start Hardhat local blockchain node (WORKS - takes 3-5 seconds)
29+
npx hardhat node
30+
# NEVER CANCEL: Node startup takes 3-5 seconds. Set timeout to 60+ seconds.
31+
32+
# Open Hardhat console without compilation (WORKS - immediate)
33+
npx hardhat console --no-compile
34+
35+
# View available Hardhat commands (immediate)
36+
npx hardhat --help
37+
38+
# List installed packages (immediate)
39+
npm list
40+
41+
# Flatten contracts for analysis (WORKS - takes 2-3 seconds)
42+
npx hardhat flatten contracts/SEQToken.sol
43+
npx hardhat flatten contracts/SEQICO.sol
44+
# NEVER CANCEL: Flatten takes 2-3 seconds. Set timeout to 30+ seconds.
45+
```
46+
47+
### Working in Unrestricted Environment
48+
49+
In a normal development environment with internet access, these commands should work:
50+
51+
```bash
52+
# Compile smart contracts (takes 30-60 seconds)
53+
npx hardhat compile
54+
# NEVER CANCEL: Compilation takes 30-60 seconds. Set timeout to 120+ seconds.
55+
56+
# Deploy contracts to local network
57+
npx hardhat run scripts/deploy.js
58+
npx hardhat run scripts/deploy-DE.js
59+
60+
# Deploy to specific network
61+
npx hardhat run scripts/deploy.js --network localhost
62+
```
63+
64+
### Node.js Version Warning
65+
The project shows warnings about Node.js 20.19.4 not being supported. Hardhat recommends Node.js 22.10.0+ for optimal compatibility, but the project works with current version.
66+
67+
## Project Structure
68+
69+
### Smart Contracts (`/contracts/`)
70+
- **SEQICO.sol**: Main ICO contract with functions:
71+
- `buyWithETH(uint256 tokenAmount)`: Purchase tokens with ETH
72+
- `buyWithUSDT(uint256 tokenAmount)`: Purchase tokens with USDT
73+
- `buyWithUSDC(uint256 tokenAmount)`: Purchase tokens with USDC
74+
- `setSEQToken(address _seqToken)`: Update SEQ token address (owner only)
75+
- `withdrawETH(address payable recipient)`: Withdraw collected ETH (owner only)
76+
- `withdrawERC20(address token, address recipient)`: Withdraw ERC20 tokens (owner only)
77+
78+
- **SEQToken.sol**: Standard ERC20 token contract
79+
- Total supply: 500,000 SEQ tokens
80+
- Initial distribution: 10% to owner, 90% to ICO contract
81+
82+
### Deployment Scripts (`/scripts/`)
83+
- **deploy.js**: Main deployment script with detailed comments
84+
- **deploy-DE.js**: Alternative deployment script (virtually identical to deploy.js, only minor comment differences)
85+
86+
Both scripts perform the same deployment sequence:
87+
1. Deploy SEQICO contract with dummy token address
88+
2. Deploy SEQToken with 10% to owner, 90% to ICO
89+
3. Update SEQICO with real SEQToken address
90+
4. Print balances for verification
91+
92+
### Configuration
93+
- **hardhat.config.js**: Basic Hardhat configuration specifying Solidity version 0.8.24
94+
- **package.json**: Project dependencies including Hardhat 3.0.3, hardhat-toolbox 6.1.0, OpenZeppelin contracts 5.4.0
95+
96+
## Contract Analysis
97+
98+
### Working Contract Inspection Commands
99+
Even without compilation, you can analyze the contract structure:
100+
101+
```bash
102+
# View contract source code
103+
cat contracts/SEQToken.sol
104+
cat contracts/SEQICO.sol
105+
106+
# Flatten contracts to see all dependencies (works in restricted environment)
107+
npx hardhat flatten contracts/SEQToken.sol > /tmp/SEQToken-flattened.sol
108+
npx hardhat flatten contracts/SEQICO.sol > /tmp/SEQICO-flattened.sol
109+
110+
# Count lines of code in contracts
111+
find contracts/ -name "*.sol" -exec wc -l {} \;
112+
113+
# Search for specific patterns in contracts
114+
grep -n "function\|event\|modifier" contracts/*.sol
115+
```
116+
117+
## Validation
118+
119+
### Manual Testing Scenarios
120+
When network restrictions allow compilation and deployment:
121+
1. **Deploy and verify contracts**: Run deployment script and check that both contracts deploy successfully
122+
2. **Verify token distribution**: Confirm owner receives 10% and ICO contract receives 90% of tokens
123+
3. **Test ICO functionality**: Verify buying tokens with ETH works correctly
124+
4. **Test owner functions**: Verify only owner can call restricted functions
125+
126+
### Development Workflow
127+
```bash
128+
# Start local blockchain (always works - takes 3-5 seconds)
129+
npx hardhat node
130+
131+
# In separate terminal, deploy contracts (requires unrestricted network)
132+
npx hardhat run scripts/deploy.js --network localhost
133+
134+
# Interact with contracts via console
135+
npx hardhat console --network localhost
136+
137+
# Analyze contract structure (works in restricted environment)
138+
npx hardhat flatten contracts/SEQToken.sol
139+
npx hardhat flatten contracts/SEQICO.sol
140+
```
141+
142+
## Common Issues
143+
144+
### Dependency Installation
145+
- **Problem**: `npm install` fails with ERESOLVE errors
146+
- **Solution**: Always use `npm install --legacy-peer-deps`
147+
148+
### Compilation Failures
149+
- **Problem**: Cannot download Solidity compiler due to network restrictions
150+
- **Solution**: No workaround available in restricted environments. Document this limitation and provide alternative testing approaches.
151+
152+
### No Test Suite
153+
The project currently has no test suite (package.json shows placeholder test command that exits with error). If adding tests:
154+
- Create test files in `/test/` directory
155+
- Use Hardhat testing framework with Mocha/Chai
156+
- Test both SEQICO and SEQToken functionality
157+
158+
## Repository Quick Reference
159+
160+
### Key Files Listing
161+
```
162+
.
163+
├── README.md # Project documentation
164+
├── package.json # Dependencies and scripts
165+
├── hardhat.config.js # Hardhat configuration
166+
├── contracts/
167+
│ ├── SEQICO.sol # ICO smart contract
168+
│ └── SEQToken.sol # ERC20 token contract
169+
└── scripts/
170+
├── deploy.js # Main deployment script
171+
└── deploy-DE.js # Alternative deployment script
172+
```
173+
174+
### Package.json Dependencies
175+
```json
176+
{
177+
"devDependencies": {
178+
"@nomicfoundation/hardhat-toolbox": "^6.1.0",
179+
"@openzeppelin/contracts": "^5.4.0",
180+
"hardhat": "^3.0.3"
181+
}
182+
}
183+
```
184+
185+
## Important Notes
186+
187+
- **NEVER CANCEL** long-running operations. Compilation and deployment can take 60+ seconds.
188+
- Always use `--legacy-peer-deps` for npm operations.
189+
- The two deployment scripts are functionally identical.
190+
- Network restrictions prevent standard Hardhat compilation in some environments.
191+
- No test suite exists - create tests if functionality changes are made.
192+
- Use Hardhat console with `--no-compile` flag for immediate access without compilation.

0 commit comments

Comments
 (0)