import { ethers } from 'ethers'; import { BridgeBroker, ChainId, CollectionCreator, DeployType, OmniteLayerZeroBridgeReceiver, config, } from 'omnite-sdk'; import { extractAddressFromLogs } from './helpers'; const collectionName = 'OmniCollection'; const collectionTicker = 'OMNI'; const sourceChainId = ChainId.BSCT; const targetChainId = ChainId.RINKEBY; const main = async () => { console.log('Running deployment'); await config.initialize({ supportedChains: [ChainId.BSCT, ChainId.RINKEBY], moralisApiKey: '', pinataJWTToken: '', providerRpcUrls: { [ChainId.BSCT]: 'https://data-seed-prebsc-1-s1.binance.org:8545/', [ChainId.RINKEBY]: 'https://rinkeby.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161', }, }); const provider = new ethers.providers.JsonRpcProvider( 'https://data-seed-prebsc-1-s1.binance.org:8545/' ); const wallet = new ethers.Wallet( process.env.PRIVATEKEY, provider ) as unknown as ethers.providers.JsonRpcSigner; // Prepare collection creator for deployment const collectionCreator = new CollectionCreator( sourceChainId, wallet, DeployType.native, { collectionName, collectionTicker, userAddress: await wallet.getAddress(), }, [BridgeBroker.LayerZero], // facets support BridgeBroker.LayerZero, [ { amount: 10, chainId: sourceChainId }, { amount: 10, chainId: targetChainId }, ] ); // We want collection to have baseToken with tokenId as tokenURI, so we need to provide it collectionCreator.baseTokenUri = 'ipfs://QmNNvuUaB5cd8mP7oMhcEeax1AMSHcWfp2GzY3YfoZJLD3/'; // Execute deployment const result = await collectionCreator.deploy(); console.log('Tx hash:', result.hash); // Waiting for deployment trasnaction to be confirmed const receipt = await result.wait(); const createdAddress = extractAddressFromLogs(receipt.logs); console.log('Waiting for deployment to arrive on target chain'); const targetChainCreatedContractAddress = await OmniteLayerZeroBridgeReceiver.waitContractDeployed( targetChainId, config.getChainConfig(sourceChainId).layerZeroChainId ); console.log('https://testnet.bscscan.com/token/' + createdAddress); console.log( 'https://rinkeby.etherscan.io/token/' + targetChainCreatedContractAddress ); }; main();