forked from ava-labs/EncryptedERC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-converter.ts
More file actions
69 lines (59 loc) · 1.88 KB
/
deploy-converter.ts
File metadata and controls
69 lines (59 loc) · 1.88 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
import { ethers } from "hardhat";
import { deployLibrary } from "../test/helpers";
import { EncryptedERC__factory } from "../typechain-types";
import { DECIMALS } from "./constants";
import { deployProductionVerifiers } from "./helpers";
const main = async () => {
// get deployer
const [deployer] = await ethers.getSigners();
// deploy verifiers
const {
registrationVerifier,
mintVerifier,
withdrawVerifier,
transferVerifier,
} = await deployProductionVerifiers(deployer);
// deploy babyjub library
const babyJubJub = await deployLibrary(deployer);
// deploy registrar contract
const registrarFactory = await ethers.getContractFactory("Registrar");
const registrar = await registrarFactory.deploy(registrationVerifier);
await registrar.waitForDeployment();
// deploy eERC20
const encryptedERCFactory = new EncryptedERC__factory({
"contracts/libraries/BabyJubJub.sol:BabyJubJub": babyJubJub,
});
const encryptedERC_ = await encryptedERCFactory.connect(deployer).deploy({
registrar: registrar.target,
isConverter: true, // This is a converter eERC
name: "",
symbol: "",
mintVerifier,
withdrawVerifier,
transferVerifier,
decimals: DECIMALS,
});
await encryptedERC_.waitForDeployment();
// also deploys new erc20
const erc20Factory = await ethers.getContractFactory("SimpleERC20");
const erc20 = await erc20Factory.deploy("Test", "TEST", 18);
await erc20.waitForDeployment();
// mints some amount to deployer as well
const tx = await erc20.mint(deployer.address, ethers.parseEther("10000"));
await tx.wait();
console.log("ERC20 deployed at:", erc20.target);
console.log("Minted 10000 erc20 to deployer");
console.table({
registrationVerifier,
mintVerifier,
withdrawVerifier,
transferVerifier,
babyJubJub,
registrar: registrar.target,
encryptedERC: encryptedERC_.target,
});
};
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});