Files
asle/scripts/deploy-avalanche.ts
defiQUG 507d9a35b1 Add initial project structure and documentation files
- Created .gitignore to exclude sensitive files and directories.
- Added API documentation in API_DOCUMENTATION.md.
- Included deployment instructions in DEPLOYMENT.md.
- Established project structure documentation in PROJECT_STRUCTURE.md.
- Updated README.md with project status and team information.
- Added recommendations and status tracking documents.
- Introduced testing guidelines in TESTING.md.
- Set up CI workflow in .github/workflows/ci.yml.
- Created Dockerfile for backend and frontend setups.
- Added various service and utility files for backend functionality.
- Implemented frontend components and pages for user interface.
- Included mobile app structure and services.
- Established scripts for deployment across multiple chains.
2025-12-03 21:22:31 -08:00

87 lines
3.0 KiB
TypeScript

import { ethers } from "hardhat";
import * as fs from "fs";
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying to Avalanche with account:", deployer.address);
const chainId = 43114;
const rpcUrl = process.env.AVALANCHE_RPC_URL || "https://api.avax.network/ext/bc/C/rpc";
const ccipRouter = process.env.AVALANCHE_CCIP_ROUTER || "0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D";
const chainSelector = BigInt('6433500567565415381');
console.log(`\n=== Deploying to Avalanche (Chain ID: ${chainId}) ===`);
try {
// Deploy Diamond
const Diamond = await ethers.getContractFactory("Diamond");
const diamond = await Diamond.deploy();
await diamond.waitForDeployment();
const diamondAddress = await diamond.getAddress();
console.log(`Diamond deployed to: ${diamondAddress}`);
// Deploy Facets
const facets = {
DiamondCutFacet: await (await ethers.getContractFactory("DiamondCutFacet")).deploy(),
LiquidityFacet: await (await ethers.getContractFactory("LiquidityFacet")).deploy(),
VaultFacet: await (await ethers.getContractFactory("VaultFacet")).deploy(),
ComplianceFacet: await (await ethers.getContractFactory("ComplianceFacet")).deploy(),
CCIPFacet: await (await ethers.getContractFactory("CCIPFacet")).deploy(),
GovernanceFacet: await (await ethers.getContractFactory("GovernanceFacet")).deploy(),
SecurityFacet: await (await ethers.getContractFactory("SecurityFacet")).deploy(),
ChainConfigFacet: await (await ethers.getContractFactory("ChainConfigFacet")).deploy(),
};
console.log("Facets deployed");
// Configure CCIP
const ccipFacet = await ethers.getContractAt("CCIPFacet", diamondAddress);
await ccipFacet.setCCIPRouter(ccipRouter);
await ccipFacet.setChainSelector(chainId, chainSelector);
console.log(`CCIP Router configured: ${ccipRouter}`);
// Configure ChainConfig
const chainConfigFacet = await ethers.getContractAt("ChainConfigFacet", diamondAddress);
await chainConfigFacet.setChainConfig(
chainId,
"Avalanche",
ethers.ZeroAddress,
"https://snowtrace.io",
BigInt(3000000),
BigInt(300)
);
await chainConfigFacet.setChainActive(chainId, true);
const deployment = {
diamond: diamondAddress,
facets: Object.fromEntries(
Object.entries(facets).map(([name, contract]) => [name, await contract.getAddress()])
),
chainId: chainId,
chainName: "Avalanche",
ccipRouter,
chainSelector: chainSelector.toString(),
};
console.log(`✓ Avalanche deployment complete`);
console.log(JSON.stringify(deployment, null, 2));
// Write to file
fs.writeFileSync(
`deployments-avalanche-${chainId}.json`,
JSON.stringify(deployment, null, 2)
);
} catch (error) {
console.error(`✗ Failed to deploy to Avalanche:`, error);
throw error;
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});