Skip to content

Latest commit

 

History

History
130 lines (113 loc) · 3.74 KB

gov.md

File metadata and controls

130 lines (113 loc) · 3.74 KB

PLUGCHAIN SDK GO

GOV MODULE

realization

Query

QueryProposal

Detailed information on a single proposal

rep, err := client.Gov.QueryProposal(6)

QueryProposals

Filter proposals by status. If not filled in, all proposals will be filtered

pro, err := client.Gov.QueryProposals("") //PROPOSAL_STATUS_DEPOSIT_PERIOD

QueryVote

Query the details of a vote

vote, err := client.Gov.QueryVote(5, "gx1yhf7w0sq8yn6gqre2pulnqwyy30tjfc4v08f3x")

QueryVotes

Query proposal vote

vote, err := client.Gov.QueryVotes(5)

QueryParams

Query the parameters of the governance process

vote, err := client.Gov.QueryParams("voting")

QueryDeposit

Mortgage information from a mortgager in the proposal by proposing ID query

resp, err := client.Gov.QueryDeposit(2, "gx1yhf7w0sq8yn6gqre2pulnqwyy30tjfc4v08f3x")

QueryDeposits

Query all mortgage information in the proposal

resp, err := client.Gov.QueryDeposits(2)

QueryTallyResult

Query the vote counting result of the proposal

vote, err := client.Gov.QueryTallyResult(5)

TX

SubmitProposal

Submit proposals with initial delegation. The title, description, type and mortgage of the proposal can be provided directly You need to import the private key before you can operate,Please see the key package for importing the private key

baseTx := types.BaseTx{
    From:     "demo", //Account name 
    Password: "123123123",
    Gas:      200000,
    Mode:     types.Commit,
    Memo:     "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
proposalId, res, err := client.Gov.SubmitProposal(gov.SubmitProposalRequest{
	Title:          "Community Pool Spend",
	Description:    "Pay me some Atoms!",
	Type:           "Text",
	InitialDeposit: types.NewDecCoins(types.NewDecCoin("uplugcn", types.NewInt(1000))),
}, baseTx)

Deposit

Pledge tokens for a proposal You need to import the private key before you can operate,Please see the key package for importing the private key

baseTx := types.BaseTx{
    From:     "demo", //Account name 
    Password: "123123123",
    Gas:      200000,
    Mode:     types.Commit,
    Memo:     "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
amount, err := types.ParseDecCoins("2000uplugcn")
res, err := client.Gov.Deposit(gov.DepositRequest{
	ProposalId: 3,
	Amount:     amount,
}, baseTx)

Vote

Proposal voting You need to import the private key before you can operate,Please see the key package for importing the private key

baseTx := types.BaseTx{
    From:     "demo", //Account name 
    Password: "123123123",
    Gas:      200000,
    Mode:     types.Commit,
    Memo:     "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
voteReq := gov.VoteRequest{
	ProposalId: 5,
	Option:     "VOTE_OPTION_YES",
}
res, err := client.Gov.Vote(voteReq, baseTx)