231 lines
6.0 KiB
Markdown
231 lines
6.0 KiB
Markdown
|
|
# Remix IDE Deployment Guide - ChainID 138
|
||
|
|
|
||
|
|
**Date**: 2025-01-12
|
||
|
|
**Purpose**: Guide for deploying contracts via Remix IDE when direct deployment fails
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
Remix IDE provides an alternative deployment method that may work when direct `forge` deployment fails. This guide walks through deploying contracts to ChainID 138 using Remix IDE.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Prerequisites
|
||
|
|
|
||
|
|
1. **Remix IDE Access**
|
||
|
|
- Visit: https://remix.ethereum.org
|
||
|
|
- No account required (works in browser)
|
||
|
|
|
||
|
|
2. **Network Configuration**
|
||
|
|
- RPC Endpoint: `http://192.168.11.250:8545`
|
||
|
|
- ChainID: 138
|
||
|
|
- Network Name: DBIS Chain
|
||
|
|
|
||
|
|
3. **Deployer Account**
|
||
|
|
- Private Key: (from `.env` file)
|
||
|
|
- Address: `0x4A666F96fC8764181194447A7dFdb7d471b301C8`
|
||
|
|
- Balance: 999M+ ETH
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Step-by-Step Deployment
|
||
|
|
|
||
|
|
### Step 1: Connect to Remix IDE
|
||
|
|
|
||
|
|
1. Open browser and navigate to: https://remix.ethereum.org
|
||
|
|
2. Wait for Remix IDE to load completely
|
||
|
|
|
||
|
|
### Step 2: Create Contract File
|
||
|
|
|
||
|
|
1. In Remix IDE, click **"File Explorer"** in the left sidebar
|
||
|
|
2. Click **"Create New File"**
|
||
|
|
3. Name the file: `MockLinkToken.sol`
|
||
|
|
4. Copy the contract code:
|
||
|
|
|
||
|
|
```solidity
|
||
|
|
// SPDX-License-Identifier: MIT
|
||
|
|
pragma solidity ^0.8.19;
|
||
|
|
|
||
|
|
contract MockLinkToken {
|
||
|
|
string public name = "Chainlink Token";
|
||
|
|
string public symbol = "LINK";
|
||
|
|
uint8 public decimals = 18;
|
||
|
|
uint256 public totalSupply;
|
||
|
|
|
||
|
|
mapping(address => uint256) public balanceOf;
|
||
|
|
mapping(address => mapping(address => uint256)) public allowance;
|
||
|
|
|
||
|
|
event Transfer(address indexed from, address indexed to, uint256 value);
|
||
|
|
event Approval(address indexed owner, address indexed spender, uint256 value);
|
||
|
|
|
||
|
|
constructor() {
|
||
|
|
totalSupply = 1000000000 * 10**18; // 1 billion tokens
|
||
|
|
balanceOf[msg.sender] = totalSupply;
|
||
|
|
emit Transfer(address(0), msg.sender, totalSupply);
|
||
|
|
}
|
||
|
|
|
||
|
|
function transfer(address to, uint256 value) external returns (bool) {
|
||
|
|
require(balanceOf[msg.sender] >= value, "Insufficient balance");
|
||
|
|
balanceOf[msg.sender] -= value;
|
||
|
|
balanceOf[to] += value;
|
||
|
|
emit Transfer(msg.sender, to, value);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
function approve(address spender, uint256 value) external returns (bool) {
|
||
|
|
allowance[msg.sender][spender] = value;
|
||
|
|
emit Approval(msg.sender, spender, value);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
function transferFrom(address from, address to, uint256 value) external returns (bool) {
|
||
|
|
require(balanceOf[from] >= value, "Insufficient balance");
|
||
|
|
require(allowance[from][msg.sender] >= value, "Insufficient allowance");
|
||
|
|
balanceOf[from] -= value;
|
||
|
|
balanceOf[to] += value;
|
||
|
|
allowance[from][msg.sender] -= value;
|
||
|
|
emit Transfer(from, to, value);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### Step 3: Compile Contract
|
||
|
|
|
||
|
|
1. Click **"Solidity Compiler"** in the left sidebar
|
||
|
|
2. Select compiler version: **0.8.19** (or compatible)
|
||
|
|
3. Click **"Compile MockLinkToken.sol"**
|
||
|
|
4. Wait for compilation to complete (check for green checkmark)
|
||
|
|
|
||
|
|
### Step 4: Configure Network Connection
|
||
|
|
|
||
|
|
1. Click **"Deploy & Run Transactions"** in the left sidebar
|
||
|
|
2. Under **"Environment"**, select **"Injected Provider - MetaMask"** or **"Custom"**
|
||
|
|
3. If using Custom:
|
||
|
|
- Click **"Add Network"**
|
||
|
|
- Network Name: `DBIS Chain`
|
||
|
|
- RPC URL: `http://192.168.11.250:8545`
|
||
|
|
- Chain ID: `138`
|
||
|
|
- Currency Symbol: `ETH`
|
||
|
|
- Block Explorer: `https://explorer.d-bis.org`
|
||
|
|
|
||
|
|
### Step 5: Connect Wallet
|
||
|
|
|
||
|
|
1. If using MetaMask:
|
||
|
|
- Click **"Connect to MetaMask"**
|
||
|
|
- Approve connection in MetaMask
|
||
|
|
- Ensure correct account is selected
|
||
|
|
|
||
|
|
2. If using Custom Provider:
|
||
|
|
- Enter your private key (from `.env` file)
|
||
|
|
- **⚠️ WARNING**: Only use in secure environment
|
||
|
|
- Click **"Connect"**
|
||
|
|
|
||
|
|
### Step 6: Deploy Contract
|
||
|
|
|
||
|
|
1. In **"Deploy & Run Transactions"**:
|
||
|
|
- Select contract: **"MockLinkToken"**
|
||
|
|
- Constructor parameters: (none required)
|
||
|
|
- Click **"Deploy"**
|
||
|
|
|
||
|
|
2. Wait for deployment:
|
||
|
|
- Transaction will appear in transaction list
|
||
|
|
- Wait for confirmation
|
||
|
|
- Check transaction status
|
||
|
|
|
||
|
|
### Step 7: Verify Deployment
|
||
|
|
|
||
|
|
1. After deployment, contract address will appear
|
||
|
|
2. Click on contract address to view details
|
||
|
|
3. Test contract functions:
|
||
|
|
- `name()` - Should return "Chainlink Token"
|
||
|
|
- `symbol()` - Should return "LINK"
|
||
|
|
- `totalSupply()` - Should return 1000000000000000000000000000
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Troubleshooting
|
||
|
|
|
||
|
|
### Issue: Cannot Connect to Network
|
||
|
|
|
||
|
|
**Solution**:
|
||
|
|
- Verify RPC endpoint is accessible: `http://192.168.11.250:8545`
|
||
|
|
- Check if network allows external connections
|
||
|
|
- Try using MetaMask with custom network
|
||
|
|
|
||
|
|
### Issue: Transaction Fails
|
||
|
|
|
||
|
|
**Solution**:
|
||
|
|
- Check deployer account balance
|
||
|
|
- Verify gas settings (increase gas limit if needed)
|
||
|
|
- Check transaction status on block explorer
|
||
|
|
|
||
|
|
### Issue: Contract Not Deployed
|
||
|
|
|
||
|
|
**Solution**:
|
||
|
|
- Verify transaction was actually sent
|
||
|
|
- Check block explorer for transaction
|
||
|
|
- Review Remix console for errors
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Alternative: Minimal Contract Test
|
||
|
|
|
||
|
|
If full contract fails, try deploying a minimal contract first:
|
||
|
|
|
||
|
|
```solidity
|
||
|
|
// SPDX-License-Identifier: MIT
|
||
|
|
pragma solidity ^0.8.19;
|
||
|
|
|
||
|
|
contract TestMinimal {
|
||
|
|
uint256 public x = 1;
|
||
|
|
|
||
|
|
function setX(uint256 _x) external {
|
||
|
|
x = _x;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
This minimal contract (204 bytes) can help verify if the issue is contract-specific or network-wide.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Security Notes
|
||
|
|
|
||
|
|
1. **Private Key Security**
|
||
|
|
- Never share your private key
|
||
|
|
- Only use Remix IDE in secure environment
|
||
|
|
- Consider using MetaMask instead of direct private key
|
||
|
|
|
||
|
|
2. **Network Security**
|
||
|
|
- Verify RPC endpoint is legitimate
|
||
|
|
- Check network configuration before connecting
|
||
|
|
- Be cautious with test networks
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Next Steps
|
||
|
|
|
||
|
|
After successful deployment:
|
||
|
|
|
||
|
|
1. **Save Contract Address**
|
||
|
|
- Copy deployed contract address
|
||
|
|
- Update `.env` file with new address
|
||
|
|
- Update configuration files
|
||
|
|
|
||
|
|
2. **Verify Contract**
|
||
|
|
- Use block explorer to verify contract
|
||
|
|
- Check contract bytecode matches source
|
||
|
|
- Verify constructor parameters
|
||
|
|
|
||
|
|
3. **Test Contract Functions**
|
||
|
|
- Test all contract functions
|
||
|
|
- Verify contract behavior
|
||
|
|
- Check event emissions
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
**Last Updated**: 2025-01-12
|
||
|
|
|