Skip to content

Commit 5184b91

Browse files
committed
fix: deploy scripts updated to ethers v6
also deployed DATAv2 to Peaq chain
1 parent 8990409 commit 5184b91

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

scripts/deploy-1-datav2.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
const { ContractFactory, Wallet, getDefaultProvider } = require("ethers")
1+
const { ContractFactory, Wallet, JsonRpcProvider, getDefaultProvider } = require("ethers")
22

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

5-
const { KEY } = process.env
5+
const { KEY, ETHEREUM_RPC_URL } = process.env
66

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

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

1314
async function main() {
1415

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

1920
await token.waitForDeployment()
21+
const tokenAddress = await token.getAddress()
2022

21-
console.log("DATAv2 deployed to:", token.address)
23+
console.log("DATAv2 deployed to:", tokenAddress)
2224
}
2325

2426
// We recommend this pattern to be able to use async/await everywhere

scripts/deploy-2-migrator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ async function main() {
1717

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

2222
await migrator.waitForDeployment()
2323

24-
console.log("DataTokenMigrator deployed to:", migrator.address)
24+
console.log("DataTokenMigrator deployed to:", await migrator.getAddress())
2525
}
2626

2727
// We recommend this pattern to be able to use async/await everywhere

scripts/deploy-without-migrator.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/usr/bin/env node
22

3+
// PEAQ chain
4+
const providerUrl = "https://peaq.api.onfinality.io/public"
5+
const explorerUrl = "https://peaq.subscan.io/tx"
6+
37
// Binance Smart Chain
4-
const providerUrl = "https://bsc-dataseed.binance.org/"
5-
const explorerUrl = "https://bscscan.com/tx"
8+
// const providerUrl = "https://bsc-dataseed.binance.org/"
9+
// const explorerUrl = "https://bscscan.com/tx"
610

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

1721

18-
const { ContractFactory, Wallet, providers: { JsonRpcProvider }, utils: { id } } = require("ethers")
22+
const { ContractFactory, Wallet, JsonRpcProvider, id } = require("ethers")
1923

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

2933
async function main() {
30-
3134
const DATAv2 = new ContractFactory(DATAv2Json.abi, DATAv2Json.bytecode, deployer)
3235
const token = await DATAv2.deploy() // plain token
3336
// const token = await DATAv2.deploy("0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa") // Matic's Polygon version of the token
34-
console.log("Follow deployment: %s/%s", explorerUrl, token.deployTransaction.hash)
37+
console.log("Follow deployment: %s/%s", explorerUrl, token.deploymentTransaction().hash)
3538

3639
await token.waitForDeployment()
37-
console.log("DATAv2 deployed to:", token.address)
40+
const tokenAddress = await token.getAddress()
41+
console.log("DATAv2 deployed to:", tokenAddress)
3842

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

50-
// We recommend this pattern to be able to use async/await everywhere
51-
// and properly handle errors.
5254
main()
5355
.then(() => process.exit(0))
5456
.catch(error => {

0 commit comments

Comments
 (0)