diff --git a/scripts/deploy-subnet-registrator.ts b/scripts/deploy-subnet-registrator.ts new file mode 100644 index 0000000..a072125 --- /dev/null +++ b/scripts/deploy-subnet-registrator.ts @@ -0,0 +1,28 @@ +import { providers, utils, Wallet } from 'ethers' +import subnetRegistratorJSON from '../artifacts/contracts/topos-core/SubnetRegistrator.sol/SubnetRegistrator.json' +import { Arg, deployContractConstant } from './const-addr-deployer' + +const main = async function (..._args: Arg[]) { + const [providerEndpoint, privateKey, salt, gasLimit, ...args] = _args + const provider = new providers.JsonRpcProvider(providerEndpoint) + + if (!privateKey || !utils.isHexString('0x' + privateKey, 32)) { + console.error('ERROR: Please provide a valid private key!') + return + } + + const wallet = new Wallet('0x' + privateKey || '', provider) + const address = await deployContractConstant( + wallet, + subnetRegistratorJSON, + salt, + [wallet.address, ...args], + gasLimit + ) + .then(({ address }) => address) + .catch(console.error) + console.log(address) +} + +const args = process.argv.slice(2) +main(...args)