-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathcreateERC20Rollup.ts
More file actions
74 lines (65 loc) · 1.9 KB
/
createERC20Rollup.ts
File metadata and controls
74 lines (65 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { ethers } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { Signer } from 'ethers'
import { createRollup } from './rollupCreation'
import { TestToken__factory } from '../build/types'
async function deployERC20Token(deployer: Signer): Promise<string> {
const factory = await new TestToken__factory(deployer).deploy(
ethers.utils.parseEther('1000000000')
)
const feeToken = await factory.deployed()
return feeToken.address
}
async function main() {
const [deployer] = await ethers.getSigners()
let customFeeTokenAddress = process.env.FEE_TOKEN_ADDRESS
if (!customFeeTokenAddress) {
console.log(
'FEE_TOKEN_ADDRESS env var not provided, deploying new ERC20 token'
)
customFeeTokenAddress = await deployERC20Token(deployer)
}
if (!ethers.utils.isAddress(customFeeTokenAddress)) {
throw new Error(
'Fee token address ' + customFeeTokenAddress + ' is not a valid address!'
)
}
const rollupCreatorAddress = process.env.ROLLUP_CREATOR_ADDRESS
if (!rollupCreatorAddress) {
throw new Error('ROLLUP_CREATOR_ADDRESS not set')
}
const stakeTokenAddress = process.env.STAKE_TOKEN_ADDRESS
if (!stakeTokenAddress) {
throw new Error('STAKE_TOKEN_ADDRESS not set')
}
let feeTokenPricer = process.env.FEE_TOKEN_PRICER_ADDRESS
if (!feeTokenPricer) {
feeTokenPricer = ethers.constants.AddressZero
}
let customOsp = process.env.CUSTOM_OSP_ADDRESS as string
if (!customOsp) {
customOsp = ethers.constants.AddressZero
}
console.log(
'Creating new rollup with',
customFeeTokenAddress,
'as fee token and',
feeTokenPricer,
'as fee token pricer'
)
await createRollup(
deployer,
false,
rollupCreatorAddress,
customFeeTokenAddress,
feeTokenPricer,
stakeTokenAddress,
customOsp
)
}
main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error)
process.exit(1)
})