-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy path00_resolve_nucypher_token.ts
More file actions
59 lines (49 loc) · 1.96 KB
/
00_resolve_nucypher_token.ts
File metadata and controls
59 lines (49 loc) · 1.96 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
import type {
HardhatRuntimeEnvironment,
HardhatNetworkConfig,
} from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments, helpers } = hre
const { log } = deployments
const { deployer } = await getNamedAccounts()
const { execute, read } = deployments
const { to1e18, from1e18 } = helpers.number
const NuCypherToken = await deployments.getOrNull("NuCypherToken")
if (NuCypherToken && helpers.address.isValid(NuCypherToken.address)) {
log(`using existing NuCypherToken at ${NuCypherToken.address}`)
// Save deployment artifact of external contract to include it in the package.
await deployments.save("NuCypherToken", NuCypherToken)
} else if (
// TODO: For testnets currently we deploy a stub contract. We should consider
// switching to an actual contract.
hre.network.name !== "goerli" &&
(!hre.network.tags.allowStubs ||
(hre.network.config as HardhatNetworkConfig)?.forking?.enabled)
) {
throw new Error("deployed NuCypherToken contract not found")
} else {
log(`deploying NuCypherToken stub`)
// To make a testnet deployment that is closer to the real setting we want
// to mint 1.34B NU tokens. The NuCyppher team deployed the token with a
// 3.8B supply, but most of it is on escrow in the `StakingEscrow` contract.
// The actual issued supply to date is around 1.34B, and it will still be
// around that number when the merge happens.
const NU_SUPPLY = to1e18("1340000000") // 1.34B NU
await deployments.deploy("NuCypherToken", {
contract: "TestToken",
from: deployer,
log: true,
})
await execute(
"NuCypherToken",
{ from: deployer },
"mint",
deployer,
NU_SUPPLY
)
log(`minted ${from1e18(await read("NuCypherToken", "totalSupply"))} NU`)
}
}
export default func
func.tags = ["NuCypherToken"]