プロポーザルに投票できるようにしよう
📜 プロポーザルを作成する
トレジャリーと投票の準備ができたので、早速提案を作成してみましょう!
まず、src/scripts/10-create-vote-proposals.ts
を作成し、以下のとおりコードを変更します。
import { ethers } from "ethers";
import sdk from "./1-initialize-sdk";
import { ERCTokenAddress, governanceAddress } from "./module";
// 投票コントラクトのアドレスを設定します
const vote = sdk.getContract(governanceAddress, "vote");
// ERC-20 コントラクトのアドレスを設定します。
const token = sdk.getContract(ERCTokenAddress, "token");
(async () => {
try {
// トレジャリーに 420,000 のトークンを新しく鋳造する提案を 作成します
const amount = 420_000;
const description =
"Should the DAO mint an additional " +
amount +
" tokens into the treasury?";
const executions = [
{
// mint を実行するトークンのコントラクトアドレスを設定します
toAddress: (await token).getAddress(),
// DAO のネイティブトークンが ETH であるため、プロポーザル作成時に送信したい ETH の量を設定します(今回はトークンを新しく発行するため 0 を設定します)
nativeTokenValue: 0,
// ガバナンスコントラクトのアドレスに mint するために、金額を正しい形式(wei)に変換します
transactionData: (await token).encoder.encode("mintTo", [
(await vote).getAddress(),
ethers.utils.parseUnits(amount.toString(), 18),
]),
},
];
await (await vote).propose(description, executions);
console.log("✅ Successfully created proposal to mint tokens");
} catch (error) {
console.error("failed to create first proposal", error);
}
try {
// 6,900 のトークンを自分たちに譲渡するための提案を作成します
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 = [
{
nativeTokenValue: 0,
transactionData: (await token).encoder.encode(
// トレジャリーからウォレットへの送金を行います。
"transfer",
[
process.env.WALLET_ADDRESS!,
ethers.utils.parseUnits(amount.toString(), 18),
]
),
toAddress: (await token).getAddress(),
},
];
await (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);
}
})();
ここでは会員に投票してもらうために、2つの新しい提案を作成しています。
-
トレジャリーが42万個の新しいトークンを鋳造(mint)できるようにする提案を作成しています。
これはとても民主的なトレジャリーであるため、もしメンバーの大多数がこの提案を不賛成とした場合、この提案は否決される可能性があります。
-
トレジャリーから自分のウォレットに6,900トークンを送金する提案を作成しています。
既存のDAOでは、DAOに貢献してくれた人などのウォレットにトークンを送る際、今回のようにプロポーザルを作成するのが一般的です。
nativeTokenValue