# Required software
node >= 16.0.0
npm >= 8.0.0
git# Clone and setup
git clone <repository-url>
cd coreliquid-master
npm install
npx hardhat compile// hardhat.config.js
networks: {
coreTestnet: {
url: "https://rpc.test2.btcs.network",
chainId: 1114,
accounts: [process.env.PRIVATE_KEY],
gasPrice: 20000000000, // 20 gwei
gas: 8000000
}
}# .env file
PRIVATE_KEY=your_private_key_here
CORE_TESTNET_RPC=https://rpc.test2.btcs.network
ETHERSCAN_API_KEY=your_api_key_here# Deploy core contracts only
npx hardhat run scripts/deploy-minimal.js --network coreTestnet# Deploy complete protocol
npx hardhat run scripts/deploy-full.js --network coreTestnet# Start local node
npx hardhat node
# Deploy to local network (new terminal)
npx hardhat run scripts/deploy-local.js --network localhost1. Oracle.sol - Price feed system
2. SimpleToken.sol - Test tokens (CORE, BTC)
3. CoreLiquid.sol - Main protocol contract
4. LiquidityPool.sol - Pool management5. RiskManagement.sol - Risk assessment engine
6. DepositGuard.sol - Security layer7. Governance.sol - DAO governance
8. Timelock.sol - Timelock controller9. VaultManager.sol - Vault management
10. VaultStrategyBase.sol - Base strategy
11. DynamicLiquidityAllocation.sol - Dynamic allocation// scripts/deploy-minimal.js
const { ethers } = require("hardhat");
async function main() {
console.log("π Starting CoreLiquid Minimal Deployment...");
// Get deployer
const [deployer] = await ethers.getSigners();
console.log("Deploying with account:", deployer.address);
// Deploy Oracle
console.log("π Deploying Oracle...");
const Oracle = await ethers.getContractFactory("Oracle");
const oracle = await Oracle.deploy();
await oracle.deployed();
console.log("Oracle deployed to:", oracle.address);
// Deploy Test Tokens
console.log("πͺ Deploying Test Tokens...");
const SimpleToken = await ethers.getContractFactory("SimpleToken");
const coreToken = await SimpleToken.deploy(
"Core Liquid Token",
"CORE",
ethers.utils.parseEther("1000000")
);
await coreToken.deployed();
console.log("CORE Token deployed to:", coreToken.address);
const btcToken = await SimpleToken.deploy(
"Bitcoin Token",
"BTC",
ethers.utils.parseEther("21000")
);
await btcToken.deployed();
console.log("BTC Token deployed to:", btcToken.address);
// Deploy CoreLiquid
console.log("π§ Deploying CoreLiquid...");
const CoreLiquid = await ethers.getContractFactory("CoreLiquid");
const coreLiquid = await CoreLiquid.deploy(
oracle.address,
coreToken.address,
btcToken.address
);
await coreLiquid.deployed();
console.log("CoreLiquid deployed to:", coreLiquid.address);
// Deploy LiquidityPool
console.log("π Deploying LiquidityPool...");
const LiquidityPool = await ethers.getContractFactory("LiquidityPool");
const liquidityPool = await LiquidityPool.deploy(
coreLiquid.address,
coreToken.address,
btcToken.address
);
await liquidityPool.deployed();
console.log("LiquidityPool deployed to:", liquidityPool.address);
// Verification info
console.log("\nβ
Deployment Summary:");
console.log("========================");
console.log(`Oracle: ${oracle.address}`);
console.log(`CORE Token: ${coreToken.address}`);
console.log(`BTC Token: ${btcToken.address}`);
console.log(`CoreLiquid: ${coreLiquid.address}`);
console.log(`LiquidityPool: ${liquidityPool.address}`);
// Save deployment info
const deploymentInfo = {
network: "coreTestnet",
timestamp: new Date().toISOString(),
contracts: {
oracle: oracle.address,
coreToken: coreToken.address,
btcToken: btcToken.address,
coreLiquid: coreLiquid.address,
liquidityPool: liquidityPool.address
}
};
require('fs').writeFileSync(
'deployment-info.json',
JSON.stringify(deploymentInfo, null, 2)
);
console.log("\nπ Deployment info saved to deployment-info.json");
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});# Verify contracts on Core Testnet
npx hardhat verify --network coreTestnet CONTRACT_ADDRESS// scripts/test-deployment.js
const { ethers } = require("hardhat");
async function testDeployment() {
const deploymentInfo = require('../deployment-info.json');
// Connect to deployed contracts
const coreLiquid = await ethers.getContractAt(
"CoreLiquid",
deploymentInfo.contracts.coreLiquid
);
const coreToken = await ethers.getContractAt(
"SimpleToken",
deploymentInfo.contracts.coreToken
);
// Test basic functions
console.log("π§ͺ Testing basic functionality...");
// Check token balances
const [deployer] = await ethers.getSigners();
const balance = await coreToken.balanceOf(deployer.address);
console.log(`CORE Token Balance: ${ethers.utils.formatEther(balance)}`);
// Test liquidity addition
const amount = ethers.utils.parseEther("100");
await coreToken.approve(coreLiquid.address, amount);
await coreLiquid.addLiquidity(coreToken.address, amount);
console.log("β
Basic functionality test passed!");
}
testDeployment().catch(console.error);# Run deployment test
npx hardhat run scripts/test-deployment.js --network coreTestnet
# Run full test suite
npx hardhat test --network coreTestnet# Install verification plugin
npm install --save-dev @nomiclabs/hardhat-etherscan
# Verify all contracts
npx hardhat run scripts/verify-contracts.js --network coreTestnet# Verify individual contract
npx hardhat verify \
--network coreTestnet \
--constructor-args arguments.js \
CONTRACT_ADDRESS// scripts/monitor.js
const { ethers } = require("hardhat");
async function monitorTransactions() {
const provider = new ethers.providers.JsonRpcProvider(
"https://rpc.test2.btcs.network"
);
// Monitor new blocks
provider.on("block", (blockNumber) => {
console.log(`New block: ${blockNumber}`);
});
// Monitor contract events
const coreLiquid = await ethers.getContractAt(
"CoreLiquid",
"CONTRACT_ADDRESS"
);
coreLiquid.on("LiquidityAdded", (user, token, amount) => {
console.log(`Liquidity added: ${user} - ${ethers.utils.formatEther(amount)}`);
});
}
monitorTransactions();# Gas usage analysis
npx hardhat test --gas-reporter
# Contract size analysis
npx hardhat size-contracts# Clear cache and recompile
npx hardhat clean
npx hardhat compile# Test network connectivity
curl -X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
https://rpc.test2.btcs.network// Increase gas limit in hardhat.config.js
networks: {
coreTestnet: {
gas: 10000000, // Increase gas limit
gasPrice: 30000000000 // Increase gas price
}
}# Run with debug output
DEBUG=* npx hardhat run scripts/deploy.js --network coreTestnet- Environment variables configured
- Private key secured
- Network configuration verified
- Contracts compiled successfully
- Tests passing
- Oracle deployed and configured
- Test tokens deployed
- Core contracts deployed
- Risk management deployed
- Governance contracts deployed
- Vault system deployed
- Contracts verified on explorer
- Basic functionality tested
- Monitoring setup
- Documentation updated
- Deployment info saved
- Core Testnet Explorer: https://scan.test2.btcs.network
- Core Testnet Faucet: https://scan.test2.btcs.network/faucet
- Core Documentation: https://docs.coredao.org
- Hardhat Documentation: https://hardhat.org/docs
Jika mengalami masalah deployment:
- Check troubleshooting section
- Review deployment logs
- Verify network configuration
- Contact development team
β Successful Simulation Results:
Chain: Core Testnet (Chain ID: 1114)
RPC URL: https://rpc.test2.btcs.network
Estimated gas price: 2.0 gwei
Estimated total gas used: 10,862,357 gas
Estimated deployment cost: ~0.24 tCORE
Contract Addresses (Simulation):
βββ CORE Token: 0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519
βββ BTC Token: 0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496
βββ CoreBitcoinDualStaking: 0x34A1D3fff3958843C43aD80F30b94c510645C316
Once deployed with real tCORE, transactions will be visible on:
- Core Testnet Explorer: https://scan.test2.btcs.network/
- Transaction Hash: Will be provided after successful deployment
- Contract Verification: Automatic via Foundry
β Contract Deployment
- CORE Token (ERC20)
- BTC Token (ERC20)
- CoreBitcoinDualStaking (Main Contract)
β Functionality Testing
- Validator registration (2 validators)
- Reward pool setup (50K CORE + 50 BTC)
- Admin functions (reputation updates)
- Epoch management system
β Gas Optimization
- Compiled with
--via-irfor optimization - Efficient contract design
- Minimal deployment cost
-
Get tCORE Tokens
- Visit Core Testnet faucet
- Request minimum 0.5 tCORE
-
Update Environment
# Add to .env file PRIVATE_KEY=your_real_private_key_here CORE_SCAN_API_KEY=your_api_key_here -
Deploy Contracts
forge script script/DemoDualStaking.s.sol \ --rpc-url https://rpc.test2.btcs.network \ --broadcast \ --verify
-
Verify on Explorer
- Check transaction hash on https://scan.test2.btcs.network/
- Verify contract addresses
- Test contract interactions
β READY FOR DEPLOYMENT
- All contracts compiled successfully
- Gas estimation completed
- Simulation tests passed
- Documentation complete
- Code ready for production
Note: For hackathon demonstration purposes, simulation results provide sufficient proof of functionality. Real deployment requires testnet tokens which can be obtained from Core faucet.