Skip to content

Commit

Permalink
fix: deploy scripts updated to ethers v6
Browse files Browse the repository at this point in the history
also deployed DATAv2 to Peaq chain
  • Loading branch information
jtakalai committed May 30, 2024
1 parent 8990409 commit 5184b91
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
12 changes: 7 additions & 5 deletions scripts/deploy-1-datav2.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
const { ContractFactory, Wallet, getDefaultProvider } = require("ethers")
const { ContractFactory, Wallet, JsonRpcProvider, getDefaultProvider } = require("ethers")

const DATAv2Json = require("../artifacts/contracts/DATAv2.sol/DATAv2.json")

const { KEY } = process.env
const { KEY, ETHEREUM_RPC_URL } = process.env

if (!KEY) { throw new Error("Please provide env variable KEY") }

const provider = getDefaultProvider()
const provider = ETHEREUM_RPC_URL ? new JsonRpcProvider(ETHEREUM_RPC_URL) : getDefaultProvider()
const explorerUrl = "https://etherscan.io/tx"
const deployer = new Wallet(KEY, provider)
console.log("Deploying contracts from %s", deployer.address)

async function main() {

const DATAv2 = new ContractFactory(DATAv2Json.abi, DATAv2Json.bytecode, deployer)
const token = await DATAv2.deploy()
console.log("Follow deployment: https://etherscan.io/tx/%s", token.deployTransaction.hash)
console.log("Follow deployment: %s/%s", explorerUrl, token.deploymentTransaction().hash)

await token.waitForDeployment()
const tokenAddress = await token.getAddress()

console.log("DATAv2 deployed to:", token.address)
console.log("DATAv2 deployed to:", tokenAddress)
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy-2-migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ async function main() {

const DataTokenMigrator = new ContractFactory(DataTokenMigratorJson.abi, DataTokenMigratorJson.bytecode, deployer)
const migrator = await DataTokenMigrator.deploy(oldTokenAddress, newTokenAddress)
console.log("Follow deployment: https://etherscan.io/tx/%s", migrator.deployTransaction.hash)
console.log("Follow deployment: https://etherscan.io/tx/%s", migrator.deploymentTransaction().hash)

await migrator.waitForDeployment()

console.log("DataTokenMigrator deployed to:", migrator.address)
console.log("DataTokenMigrator deployed to:", await migrator.getAddress())
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down
18 changes: 10 additions & 8 deletions scripts/deploy-without-migrator.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env node

// PEAQ chain
const providerUrl = "https://peaq.api.onfinality.io/public"
const explorerUrl = "https://peaq.subscan.io/tx"

// Binance Smart Chain
const providerUrl = "https://bsc-dataseed.binance.org/"
const explorerUrl = "https://bscscan.com/tx"
// const providerUrl = "https://bsc-dataseed.binance.org/"
// const explorerUrl = "https://bscscan.com/tx"

// Matic's Polygon
// const providerUrl = "https://polygon-rpc.com"
Expand All @@ -15,7 +19,7 @@ const DATAv2Json = require("../artifacts/contracts/DATAv2.sol/DATAv2.json")
// const DATAv2Json = require("../artifacts/contracts/DATAv2onPolygon.sol/DATAv2onPolygon.json")


const { ContractFactory, Wallet, providers: { JsonRpcProvider }, utils: { id } } = require("ethers")
const { ContractFactory, Wallet, JsonRpcProvider, id } = require("ethers")

const { KEY } = process.env
if (!KEY) { throw new Error("Please provide env variable KEY") }
Expand All @@ -27,14 +31,14 @@ console.log("Deploying contracts from %s", deployer.address)
const adminAddress = "0x42355e7dc0A872C465bE9DE4AcAAAcB5709Ce813"

async function main() {

const DATAv2 = new ContractFactory(DATAv2Json.abi, DATAv2Json.bytecode, deployer)
const token = await DATAv2.deploy() // plain token
// const token = await DATAv2.deploy("0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa") // Matic's Polygon version of the token
console.log("Follow deployment: %s/%s", explorerUrl, token.deployTransaction.hash)
console.log("Follow deployment: %s/%s", explorerUrl, token.deploymentTransaction().hash)

await token.waitForDeployment()
console.log("DATAv2 deployed to:", token.address)
const tokenAddress = await token.getAddress()
console.log("DATAv2 deployed to:", tokenAddress)

const tx1 = await token.grantRole(id("MINTER_ROLE"), adminAddress)
console.log("Follow grant minter tx: %s/%s", explorerUrl, tx1.hash)
Expand All @@ -47,8 +51,6 @@ async function main() {
console.log("Transaction receipt: ", tr2)
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch(error => {
Expand Down

0 comments on commit 5184b91

Please sign in to comment.