Files
explorer-monorepo/docs/PREREQUISITES_COMPLETION_GUIDE.md

299 lines
6.8 KiB
Markdown

# Prerequisites Completion Guide
**Date**: 2025-01-12
**Purpose**: Complete guide for completing all prerequisites for bridge funding
---
## Prerequisites Overview
Before funding bridge contracts, you need:
1.**LINK Token Contract Deployed**
- Address: `0x326C977E6efc84E512bB9C30f76E30c160eD06FB`
- Status: ⚠️ Not deployed
2. ⚠️ **Account Has LINK Tokens**
- Required: 20 LINK minimum
- Current: 0 LINK (token not deployed)
3. ⚠️ **Bridge Contracts Funded**
- WETH9 Bridge: 10 LINK
- WETH10 Bridge: 10 LINK
---
## Step 1: Deploy LINK Token Contract
### Option A: Automated Deployment (Recommended)
```bash
cd /home/intlc/projects/proxmox/explorer-monorepo
./scripts/deploy-link-token.sh
```
**What it does**:
- Checks if LINK token already exists
- Creates a standard ERC20 LINK token contract
- Deploys to ChainID 138
- Verifies deployment
- Mints initial supply to deployer
**Requirements**:
- Foundry installed (`forge`)
- OpenZeppelin contracts available
- Sufficient ETH for gas
### Option B: Manual Deployment
If automated deployment fails, you can deploy manually:
1. **Using Remix IDE**:
- Go to https://remix.ethereum.org
- Create new file: `LinkToken.sol`
- Use standard ERC20 contract
- Deploy to ChainID 138
2. **Using Hardhat**:
```bash
npx hardhat deploy --network chain138
```
3. **Using Foundry**:
```bash
forge create LinkToken --rpc-url http://192.168.11.250:8545 --private-key $PRIVATE_KEY
```
### LINK Token Contract Specification
**Standard ERC20 Token**:
- **Name**: "Chainlink Token"
- **Symbol**: "LINK"
- **Decimals**: 18
- **Initial Supply**: 1,000,000,000 LINK (1 billion)
- **Expected Address**: `0x326C977E6efc84E512bB9C30f76E30c160eD06FB`
**Note**: The expected address may not match if not using CREATE2. Update `.env` with the actual deployed address.
---
## Step 2: Acquire LINK Tokens
### Option A: Initial Supply (If You Deployed)
If you deployed the LINK token contract, you should have received the initial supply (1 billion LINK) in your deployer account.
**Check balance**:
```bash
cast call 0x326C977E6efc84E512bB9C30f76E30c160eD06FB \
"balanceOf(address)" \
$(cast wallet address $PRIVATE_KEY) \
--rpc-url http://192.168.11.250:8545
```
### Option B: Transfer from Another Account
If LINK exists on another account:
```bash
cast send 0x326C977E6efc84E512bB9C30f76E30c160eD06FB \
"transfer(address,uint256)" \
<RECEIVER_ADDRESS> \
$(cast --to-wei 20 ether) \
--rpc-url http://192.168.11.250:8545 \
--private-key <SENDER_PRIVATE_KEY> \
--gas-price $(./scripts/get-optimal-gas-from-api.sh proposed)
```
### Option C: Bridge from Another Chain
If LINK exists on another chain (Ethereum, BSC, etc.), you can bridge it:
1. Use a cross-chain bridge
2. Select LINK token
3. Bridge to ChainID 138
4. Receive LINK on ChainID 138
### Option D: Use a Faucet (If Available)
Some test networks provide faucets. Check if ChainID 138 has a LINK faucet.
---
## Step 3: Fund Bridge Contracts
### Automated Funding
```bash
./scripts/fund-bridge-contracts.sh 10
```
This will:
- Check account LINK balance
- Transfer 10 LINK to WETH9 Bridge
- Transfer 10 LINK to WETH10 Bridge
- Verify funding
### Manual Funding
**Fund WETH9 Bridge**:
```bash
cast send 0x326C977E6efc84E512bB9C30f76E30c160eD06FB \
"transfer(address,uint256)" \
0x89dd12025bfCD38A168455A44B400e913ED33BE2 \
10000000000000000000 \
--rpc-url http://192.168.11.250:8545 \
--private-key $PRIVATE_KEY \
--gas-price $(./scripts/get-optimal-gas-from-api.sh proposed)
```
**Fund WETH10 Bridge**:
```bash
cast send 0x326C977E6efc84E512bB9C30f76E30c160eD06FB \
"transfer(address,uint256)" \
0xe0E93247376aa097dB308B92e6Ba36bA015535D0 \
10000000000000000000 \
--rpc-url http://192.168.11.250:8545 \
--private-key $PRIVATE_KEY \
--gas-price $(./scripts/get-optimal-gas-from-api.sh proposed)
```
---
## Complete All Prerequisites (Automated)
Run the complete prerequisites script:
```bash
./scripts/complete-prerequisites.sh
```
This script will:
1. ✅ Check/deploy LINK token
2. ✅ Verify account has sufficient LINK
3. ✅ Fund bridge contracts
4. ✅ Verify funding
---
## Verification
### Check LINK Token Deployment
```bash
# Check if contract exists
cast code 0x326C977E6efc84E512bB9C30f76E30c160eD06FB --rpc-url http://192.168.11.250:8545
# Check token name
cast call 0x326C977E6efc84E512bB9C30f76E30c160eD06FB "name()" --rpc-url http://192.168.11.250:8545
# Check token symbol
cast call 0x326C977E6efc84E512bB9C30f76E30c160eD06FB "symbol()" --rpc-url http://192.168.11.250:8545
```
### Check Account Balance
```bash
cast call 0x326C977E6efc84E512bB9C30f76E30c160eD06FB \
"balanceOf(address)" \
$(cast wallet address $PRIVATE_KEY) \
--rpc-url http://192.168.11.250:8545
```
### Check Bridge Contract Balances
```bash
# WETH9 Bridge
cast call 0x326C977E6efc84E512bB9C30f76E30c160eD06FB \
"balanceOf(address)" \
0x89dd12025bfCD38A168455A44B400e913ED33BE2 \
--rpc-url http://192.168.11.250:8545
# WETH10 Bridge
cast call 0x326C977E6efc84E512bB9C30f76E30c160eD06FB \
"balanceOf(address)" \
0xe0E93247376aa097dB308B92e6Ba36bA015535D0 \
--rpc-url http://192.168.11.250:8545
```
### Generate Full Report
```bash
./scripts/get-funding-report.sh
```
---
## Troubleshooting
### LINK Token Not Deploying
**Issue**: Deployment script fails
**Solutions**:
1. Check Foundry installation: `forge --version`
2. Check OpenZeppelin contracts: `forge install OpenZeppelin/openzeppelin-contracts`
3. Check ETH balance for gas
4. Try manual deployment using Remix IDE
### Insufficient LINK Balance
**Issue**: Account doesn't have enough LINK
**Solutions**:
1. If you deployed, check deployer account balance
2. Transfer from another account
3. Bridge from another chain
4. Use faucet (if available)
### Bridge Funding Fails
**Issue**: Transfer to bridge contracts fails
**Solutions**:
1. Check LINK token is deployed
2. Check account has sufficient LINK
3. Check gas price is appropriate
4. Verify bridge contract addresses are correct
---
## Next Steps
After completing prerequisites:
1. ✅ Verify funding: `./scripts/get-funding-report.sh`
2. ✅ Test bridge operations: `./scripts/wrap-and-bridge-to-ethereum.sh 0.001`
3. ✅ Monitor fees: `./scripts/monitor-fees.sh 1.0`
4. ✅ Check bridge config: `./scripts/check-bridge-config.sh`
---
## Summary
### Prerequisites Checklist
- [ ] LINK token contract deployed
- [ ] Account has 20+ LINK tokens
- [ ] WETH9 Bridge funded with 10 LINK
- [ ] WETH10 Bridge funded with 10 LINK
- [ ] All funding verified
### Quick Commands
```bash
# Complete all prerequisites
./scripts/complete-prerequisites.sh
# Or step by step:
./scripts/deploy-link-token.sh # Step 1
# Acquire LINK tokens manually # Step 2
./scripts/fund-bridge-contracts.sh 10 # Step 3
./scripts/get-funding-report.sh # Verify
```
---
**Last Updated**: 2025-01-12