|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +const fs = require("fs") |
| 4 | +const { ContractFactory, Wallet, JsonRpcProvider, ZeroAddress } = require("ethers") |
| 5 | + |
| 6 | +const DATAv2Json = require("../artifacts/contracts/CrosschainERC677.sol/CrosschainERC677.json") |
| 7 | + |
| 8 | +const { waitForTx } = require("./waitForTx") |
| 9 | + |
| 10 | +const { |
| 11 | + KEY, |
| 12 | + PROVIDER, |
| 13 | + OUTPUT_FILE, |
| 14 | + MINTER_ADDRESS, |
| 15 | + PREVIOUS_TOKEN_ADDRESS = "0x1ae24d4928a86faaacd71cf414d2b3a499adb29b", |
| 16 | +} = process.env |
| 17 | +if (!KEY) { throw new Error("Please provide env variable KEY") } |
| 18 | +if (!PROVIDER) { throw new Error("Please provide env variable PROVIDER") } |
| 19 | +if (!MINTER_ADDRESS) { throw new Error("Please provide env variable MINTER_ADDRESS") } |
| 20 | + |
| 21 | +const { log } = console |
| 22 | + |
| 23 | +const provider = new JsonRpcProvider(PROVIDER) |
| 24 | +const deployer = new Wallet(KEY, provider) |
| 25 | +log("Deploying contracts from %s", deployer.address) |
| 26 | + |
| 27 | +async function main() { |
| 28 | + log("Connected to network at %s: %s", PROVIDER, JSON.stringify(await provider.getNetwork())) |
| 29 | + |
| 30 | + const DATAv2 = new ContractFactory(DATAv2Json.abi, DATAv2Json.bytecode, deployer) |
| 31 | + const token = await DATAv2.deploy( |
| 32 | + PREVIOUS_TOKEN_ADDRESS, |
| 33 | + ZeroAddress, |
| 34 | + MINTER_ADDRESS, |
| 35 | + "Streamr", |
| 36 | + "DATA", |
| 37 | + 18, |
| 38 | + ) |
| 39 | + waitForTx("deployment", token.deploymentTransaction()) |
| 40 | + |
| 41 | + const tokenAddress = await token.getAddress() |
| 42 | + log("DATAv2 deployed to:", tokenAddress) |
| 43 | + if (OUTPUT_FILE) { |
| 44 | + fs.writeFileSync(OUTPUT_FILE, tokenAddress) |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +main() |
| 49 | + .then(() => process.exit(0)) |
| 50 | + .catch(error => { |
| 51 | + console.error(error) |
| 52 | + process.exit(1) |
| 53 | + }) |
0 commit comments