Create Proposal
Create a Token Voting Proposal
import {
CreateMajorityVotingProposalParams,
ProposalCreationSteps,
TokenVotingClient,
VoteValues,
} from "@aragon/sdk-client";
import { ProposalMetadata } from "@aragon/sdk-client-common";
import { context } from "../index";
// Create a TokenVoting client.
const tokenVotingClient: TokenVotingClient = new TokenVotingClient(
context,
);
const metadata: ProposalMetadata = {
title: "Test Proposal",
summary: "This is a short description",
description: "This is a long description",
resources: [
{
name: "Discord",
url: "https://discord.com/...",
},
{
name: "Website",
url: "https://website...",
},
],
media: {
logo: "https://...",
header: "https://...",
},
};
// Pin the metadata in IPFS to get back the URI.
const metadataUri: string = await tokenVotingClient.methods.pinMetadata(
metadata,
);
const pluginAddress: string = "0x1234567890123456789012345678901234567890"; // the address of the plugin contract containing all plugin logic.
const proposalParams: CreateMajorityVotingProposalParams = {
pluginAddress,
metadataUri,
actions: [],
startDate: new Date(),
endDate: new Date(),
executeOnPass: false,
creatorVote: VoteValues.YES, // default NO, other options: ABSTAIN, YES. This saves gas for the voting transaction.
};
// Create a proposal where members participate through token voting.
const steps = tokenVotingClient.methods.createProposal(proposalParams);
for await (const step of steps) {
try {
switch (step.key) {
case ProposalCreationSteps.CREATING:
console.log({ txHash: step.txHash });
break;
case ProposalCreationSteps.DONE:
console.log({ proposalId: step.proposalId });
break;
}
} catch (err) {
console.error(err);
}
}Last updated