Skip to content

Commit 744104a

Browse files
author
Yash Agrawal
committed
feat: update hardhat config to use either priv. key or mnemonic
1 parent 3ca4fff commit 744104a

File tree

2 files changed

+77
-18
lines changed

2 files changed

+77
-18
lines changed

hardhat.config.ts

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
13
import '@typechain/hardhat'
4+
import * as dotenv from 'dotenv'
25
import '@nomiclabs/hardhat-ethers'
36
import '@nomiclabs/hardhat-waffle'
47
import '@nomiclabs/hardhat-etherscan'
58
import type { HardhatUserConfig } from 'hardhat/config'
6-
import * as dotenv from 'dotenv'
79

810
dotenv.config()
911

1012
const mnemnoc =
1113
typeof process.env.MNEMONIC === 'undefined' ? '' : process.env.MNEMONIC
1214

15+
const privateKey =
16+
typeof process.env.PRIVATE_KEY === 'undefined' ? '' : process.env.PRIVATE_KEY
17+
1318
const config: HardhatUserConfig = {
1419
solidity: {
1520
compilers: [
@@ -36,36 +41,47 @@ const config: HardhatUserConfig = {
3641
networks: {
3742
mainnet: {
3843
url: `https://mainnet.infura.io/v3/${process.env.INFURA_KEY!}`,
39-
accounts: {
40-
mnemonic: mnemnoc,
41-
},
44+
accounts: mnemnoc
45+
? {
46+
mnemonic: mnemnoc,
47+
}
48+
: [privateKey],
4249
},
4350
arbitrumOne: {
4451
url: `https://arbitrum-mainnet.infura.io/v3/${process.env.INFURA_KEY!}`,
45-
accounts: {
46-
mnemonic: mnemnoc,
47-
},
52+
accounts: mnemnoc
53+
? {
54+
mnemonic: mnemnoc,
55+
}
56+
: [privateKey],
4857
},
4958
arbitrumRinkeby: {
5059
url: `https://arbitrum-rinkeby.infura.io/v3/${process.env.INFURA_KEY!}`,
51-
accounts: {
52-
mnemonic: mnemnoc,
53-
},
60+
accounts: mnemnoc
61+
? {
62+
mnemonic: mnemnoc,
63+
}
64+
: [privateKey],
5465
},
5566
polygonMainnet: {
5667
url: `https://polygon-mainnet.infura.io/v3/${process.env.INFURA_KEY!}`,
57-
accounts: {
58-
mnemonic: mnemnoc,
59-
},
68+
accounts: mnemnoc
69+
? {
70+
mnemonic: mnemnoc,
71+
}
72+
: [privateKey],
6073
},
6174
polygonMumbai: {
62-
url: `https://polygon-mumbai.infura.io/v3/${process.env.INFURA_KEY!}`,
63-
accounts: {
64-
mnemonic: mnemnoc,
65-
},
75+
url: `https://polygon-mumbai.g.alchemy.com/v2/${process.env
76+
.ALCHEMY_API_KEY!}`,
77+
accounts: mnemnoc
78+
? {
79+
mnemonic: mnemnoc,
80+
}
81+
: [privateKey],
6682
},
6783
},
68-
etherscan: {
84+
Etherscan: {
6985
apiKey: {
7086
...((k) => (k ? { mainnet: k } : undefined))(process.env.ETHERSCAN_KEY),
7187
...((k) => (k ? { arbitrumOne: k, arbitrumTestnet: k } : undefined))(

scripts/deploy.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { ethers } from 'hardhat'
2+
3+
async function main() {
4+
console.log('Starting deploy script on sbt-tokens...')
5+
6+
const [signer] = await ethers.getSigners()
7+
console.log('Signer is: ', signer.address)
8+
9+
// @TODO: modify this address when deploying...
10+
const proxyAdmin = '0x2e8fCbd8d3968252f1FC427Ff06928343B650bc3'
11+
12+
// >>> Deploy SBT implementation >>>
13+
console.log('Deploying SBT implementation...')
14+
const sbtFactory = await ethers.getContractFactory('SBT')
15+
const sbtImplementation = await sbtFactory.deploy()
16+
await sbtImplementation.deployed()
17+
18+
// >>> Deploy SBTProxy >>>
19+
console.log('Deploying SBT proxy...')
20+
const sbtProxyFactory = await ethers.getContractFactory('SBTProxy')
21+
const sbtProxyInstance = await sbtProxyFactory.deploy(
22+
sbtImplementation.address,
23+
proxyAdmin,
24+
ethers.utils.arrayify('0x')
25+
)
26+
await sbtProxyInstance.deployed()
27+
28+
// >>> Initialize SBT Proxy >>>
29+
console.log('Initializing SBT proxy...')
30+
const sbtProxy = sbtFactory.attach(sbtProxyInstance.address)
31+
await sbtProxy.functions.initialize(signer.address, [signer.address])
32+
33+
console.log('Signer:', signer.address)
34+
console.log('SBTProxy deployed to:', sbtProxyInstance.address)
35+
console.log('SBTImplementation deployed to:', sbtImplementation.address)
36+
}
37+
38+
main()
39+
.then(() => process.exit(0))
40+
.catch((error) => {
41+
console.error(error)
42+
process.exit(1)
43+
})

0 commit comments

Comments
 (0)