-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy path10-create-vote-proposals.js
More file actions
73 lines (65 loc) · 2.53 KB
/
10-create-vote-proposals.js
File metadata and controls
73 lines (65 loc) · 2.53 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
import sdk from "./1-initialize-sdk.js";
import { ethers } from "ethers";
// This is our governance contract.
const vote = sdk.getVote("0x74FB3B7259CE850fA3A2EED3Bf9F610fC9756164");
// This is our ERC-20 contract.
const token = sdk.getToken("0x6B8f666c5F843056DEfA2ef8124A562E5496d141");
(async () => {
try {
// Create proposal to mint 420,000 new token to the treasury.
const amount = 420_000;
const description = "Should the DAO mint an additional " + amount + " tokens into the treasury?";
const executions = [
{
// Our token contract that actually executes the mint.
toAddress: token.getAddress(),
// Our nativeToken is ETH. nativeTokenValue is the amount of ETH we want
// to send in this proposal. In this case, we're sending 0 ETH.
// We're just minting new tokens to the treasury. So, set to 0.
nativeTokenValue: 0,
// We're doing a mint! And, we're minting to the vote, which is
// acting as our treasury.
// in this case, we need to use ethers.js to convert the amount
// to the correct format. This is because the amount it requires is in wei.
transactionData: token.encoder.encode(
"mintTo", [
vote.getAddress(),
ethers.utils.parseUnits(amount.toString(), 18),
]
),
}
];
await vote.propose(description, executions);
console.log("✅ Successfully created proposal to mint tokens");
} catch (error) {
console.error("failed to create first proposal", error);
process.exit(1);
}
try {
// Create proposal to transfer ourselves 6,900 tokens for being awesome.
const amount = 6_900;
const description = "Should the DAO transfer " + amount + " tokens from the treasury to " +
process.env.WALLET_ADDRESS + " for being awesome?";
const executions = [
{
// Again, we're sending ourselves 0 ETH. Just sending our own token.
nativeTokenValue: 0,
transactionData: token.encoder.encode(
// We're doing a transfer from the treasury to our wallet.
"transfer",
[
process.env.WALLET_ADDRESS,
ethers.utils.parseUnits(amount.toString(), 18),
]
),
toAddress: token.getAddress(),
},
];
await vote.propose(description, executions);
console.log(
"✅ Successfully created proposal to reward ourselves from the treasury, let's hope people vote for it!"
);
} catch (error) {
console.error("failed to create second proposal", error);
}
})();