cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

How to vote with cosmosjs

Open laohe-adam opened this issue 1 year ago • 1 comments

const result = await signingClient.signAndBroadcast(

            address,

            [
                {
                    typeUrl: "/cosmos.gov.v1beta1.MsgVote",
                     value: {
                        proposalId:895,
                        voter: i,
                        option:1,
                        //amount: { denom: "uatom", amount: 0, },
                    },
                    },
            ],
            "auto"
                
            )
        
                // Output the result of the Tx
                console.log("Transfer result:", result)
```
/ how to fix it
```
With signing client, chain id: cosmoshub-4 , height: 19756249
Error: Broadcasting transaction failed with code 11 (codespace: sdk). Log: out of gas in location: WriteFlat; gasWanted: 43121, gasUsed: 43494: out of gas
    at SigningStargateClient.broadcastTx (d:\deskbokk\cosmjs-sandbox-master\node_modules\@cosmjs\stargate\src\stargateclient.ts:386:9)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runAll (d:\deskbokk\cosmjs-sandbox-master\投票.ts:64:24)

laohe-adam avatar Mar 29 '24 01:03 laohe-adam

https://atmoner.github.io/cosmjs-examples/broadcast/gov/MsgVote.html

seleniumforest avatar Apr 18 '24 05:04 seleniumforest