immortal-bnb/scripts/deploy-token.ts
Claude 6baff3455c
feat: Add comprehensive smart contract deployment infrastructure
Smart Contract Setup:
- Add hardhat.config.ts for BSC testnet and mainnet deployment
  - Configured for Solidity 0.8.20
  - Optimizer enabled (200 runs)
  - BSC testnet and mainnet network configurations
  - BscScan verification integration

Deployment Scripts:
- Add deploy-token.ts for IMMBOT token deployment
  - Deploy ERC20 token with 1 billion supply
  - Automatic tax configuration (2% tax)
  - Built-in burn and liquidity mechanics
  - Post-deployment verification instructions

- Add deploy-staking.ts for staking contract deployment
  - Deploy staking contract with 4 tiers
  - Automatic tier configuration (5%-50% APY)
  - Integration with token contract
  - Set staking contract on token automatically

- Add interact-contracts.ts for contract interaction
  - View token and staking information
  - Check user balances and stakes
  - View pending rewards
  - Display available actions

- Add setup-contracts.sh for dependency installation
  - Install Hardhat and OpenZeppelin contracts
  - Install verification and testing tools
  - Setup TypeChain for type generation

Documentation:
- Add contracts/README.md with comprehensive guide
  - Contract overview and features
  - Setup and installation instructions
  - Deployment procedures (testnet and mainnet)
  - Contract verification guide
  - Interaction examples
  - Security considerations
  - Troubleshooting section
  - Gas optimization tips

Environment Updates:
- Add contract deployment variables to .env.example
  - BSCSCAN_API_KEY for verification
  - BSC_TESTNET_RPC and BSC_MAINNET_RPC
  - STAKING_CONTRACT_ADDRESS placeholder

This infrastructure enables complete smart contract deployment
and interaction for the IMMBOT token and staking ecosystem.
2025-11-08 19:48:32 +00:00

85 lines
3.2 KiB
TypeScript

/**
* Deploy IMMBOT Token Contract
* Usage: npx hardhat run scripts/deploy-token.ts --network bscTestnet
*/
import { ethers } from "hardhat";
import { parseUnits } from "ethers";
async function main() {
console.log("\n๐Ÿš€ Deploying IMMBOT Token...\n");
// Get deployer
const [deployer] = await ethers.getSigners();
console.log(`Deploying with account: ${deployer.address}`);
// Check balance
const balance = await ethers.provider.getBalance(deployer.address);
console.log(`Account balance: ${ethers.formatEther(balance)} BNB\n`);
if (balance === 0n) {
throw new Error("Deployer account has no BNB for gas fees");
}
// Configuration
const INITIAL_SUPPLY = 1_000_000_000; // 1 billion tokens
console.log(`Initial supply: ${INITIAL_SUPPLY.toLocaleString()} IMMBOT\n`);
// Deploy token
console.log("Deploying IMMBotToken contract...");
const IMMBotToken = await ethers.getContractFactory("IMMBotToken");
const token = await IMMBotToken.deploy(INITIAL_SUPPLY);
await token.waitForDeployment();
const tokenAddress = await token.getAddress();
console.log("\nโœ… IMMBotToken deployed successfully!");
console.log(`โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”`);
console.log(`Contract Address: ${tokenAddress}`);
console.log(`Network: ${(await ethers.provider.getNetwork()).name}`);
console.log(`Chain ID: ${(await ethers.provider.getNetwork()).chainId}`);
console.log(`Deployer: ${deployer.address}`);
console.log(`Total Supply: ${ethers.formatEther(await token.totalSupply())} IMMBOT`);
console.log(`โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n`);
// Wait for block confirmations (for verification)
console.log("Waiting for 5 block confirmations...");
await token.deploymentTransaction()?.wait(5);
console.log("โœ… Confirmed!\n");
// Display next steps
console.log("๐Ÿ“ Next Steps:");
console.log(`1. Verify contract on BscScan:`);
console.log(` npx hardhat verify --network bscTestnet ${tokenAddress} ${INITIAL_SUPPLY}`);
console.log(`\n2. Add to .env file:`);
console.log(` IMMBOT_TOKEN_ADDRESS=${tokenAddress}`);
console.log(`\n3. Add to frontend .env:`);
console.log(` NEXT_PUBLIC_IMMBOT_TOKEN_TESTNET=${tokenAddress}`);
console.log(`\n4. Deploy staking contract:`);
console.log(` npx hardhat run scripts/deploy-staking.ts --network bscTestnet`);
console.log("");
// Save deployment info
const deploymentInfo = {
network: (await ethers.provider.getNetwork()).name,
chainId: Number((await ethers.provider.getNetwork()).chainId),
tokenAddress,
deployer: deployer.address,
initialSupply: INITIAL_SUPPLY,
timestamp: new Date().toISOString(),
blockNumber: await ethers.provider.getBlockNumber(),
};
console.log("\n๐Ÿ“„ Deployment Info:");
console.log(JSON.stringify(deploymentInfo, null, 2));
console.log("");
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error("\nโŒ Deployment failed:");
console.error(error);
process.exit(1);
});