Skip to content

Commit d9b0ec6

Browse files
committed
IoTeX deployment
1 parent ae2a6a0 commit d9b0ec6

5 files changed

+115
-16
lines changed

archive/2025-04-09-deploy-iotex.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$ ./scripts/2025-04-09-deploy-iotex-custom-token.sh [13:11:53]
2+
+ declare -p KEY
3+
+ echo 'Using deployer private key from environment variable KEY'
4+
Using deployer private key from environment variable KEY
5+
+ export PROVIDER=https://babel-api.mainnet.iotex.one
6+
+ PROVIDER=https://babel-api.mainnet.iotex.one
7+
+ export EXPLORER=https://iotexscan.io
8+
+ EXPLORER=https://iotexscan.io
9+
+ export OUTPUT_FILE=iotex-address.txt
10+
+ OUTPUT_FILE=iotex-address.txt
11+
+ export MINTER_ADDRESS=0xAe1Ba4036610cF18A2Ca6ba0f43DB957ffA21024
12+
+ MINTER_ADDRESS=0xAe1Ba4036610cF18A2Ca6ba0f43DB957ffA21024
13+
+ ./scripts/deploy-iotex.js
14+
Deploying contracts from 0xAe1Ba4036610cF18A2Ca6ba0f43DB957ffA21024
15+
Connected to network at https://babel-api.mainnet.iotex.one: {"name":"unknown","chainId":"4689"}
16+
Follow deployment: https://iotexscan.io/tx/0x712d0c9d400cf4e2a1b5e85f4e0028f100405e2148f76e847b52bd4b0a0afb8f
17+
DATAv2 deployed to: 0xD94be6fd546d4cE502CB1E870A58330Cc8869e9B
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
if declare -p KEY >/dev/null 2>&1; then
5+
echo "Using deployer private key from environment variable KEY"
6+
else
7+
read -p "Enter deployer private key: " KEY
8+
export KEY="$KEY"
9+
fi
10+
11+
export PROVIDER=https://babel-api.mainnet.iotex.one
12+
export EXPLORER=https://iotexscan.io
13+
export OUTPUT_FILE=iotex-address.txt
14+
export MINTER_ADDRESS=0xAe1Ba4036610cF18A2Ca6ba0f43DB957ffA21024
15+
./scripts/deploy-iotex.js
16+
17+
# might take a while for the iotexscan indexers to notice the contract...
18+
until npx hardhat verify --network iotex $(cat iotex-address.txt); do
19+
echo "Retrying in 10 seconds..."
20+
sleep 10
21+
done

scripts/deploy-iotex.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
})

scripts/deploy-without-migrator.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ const DATAv2Json = require("../artifacts/contracts/DATAv2.sol/DATAv2.json")
2121
const fs = require("fs")
2222
const { ContractFactory, Wallet, JsonRpcProvider, id } = require("ethers")
2323

24+
const { waitForTx } = require("./waitForTx")
25+
2426
const {
2527
KEY,
2628
PROVIDER,
27-
EXPLORER,
2829
OUTPUT_FILE,
2930
} = process.env
3031
if (!KEY) { throw new Error("Please provide env variable KEY") }
@@ -59,21 +60,6 @@ async function main() {
5960
waitForTx("grant admin role", tx2)
6061
}
6162

62-
/**
63-
* Print pretty logging for transactions
64-
* @param {string} txDescription
65-
* @param {import("ethers").ContractTransaction} tx
66-
*/
67-
async function waitForTx(txDescription, tx) {
68-
if (EXPLORER) {
69-
log("Follow %s: %s/tx/%s", txDescription, EXPLORER, tx.hash)
70-
} else {
71-
log("Waiting for %s, hash: %s", txDescription, tx.hash)
72-
}
73-
const tr = await tx.wait()
74-
log("Transaction receipt: ", tr)
75-
}
76-
7763
main()
7864
.then(() => process.exit(0))
7965
.catch(error => {

scripts/waitForTx.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const {
2+
EXPLORER,
3+
} = process.env
4+
5+
const { log } = console
6+
7+
/**
8+
* Print pretty logging for transactions
9+
* @param {string} txDescription
10+
* @param {import("ethers").ContractTransaction} tx
11+
*/
12+
13+
async function waitForTx(txDescription, tx) {
14+
if (EXPLORER) {
15+
log("Follow %s: %s/tx/%s", txDescription, EXPLORER, tx.hash)
16+
} else {
17+
log("Waiting for %s, hash: %s", txDescription, tx.hash)
18+
}
19+
const tr = await tx.wait()
20+
log("Transaction receipt: ", tr)
21+
}
22+
exports.waitForTx = waitForTx

0 commit comments

Comments
 (0)