Skip to content

Instantly share code, notes, and snippets.

@ChaituVR
Created April 24, 2024 17:13
Show Gist options
  • Save ChaituVR/db9f78a2f2a7e8347843a6a83393b032 to your computer and use it in GitHub Desktop.
Save ChaituVR/db9f78a2f2a7e8347843a6a83393b032 to your computer and use it in GitHub Desktop.
Snapshot vote with nodejs
import { Wallet } from "@ethersproject/wallet";
import { JsonRpcProvider } from "@ethersproject/providers";
import snapshot from "@snapshot-labs/snapshot.js";
const mnemonic = "announce room limb pattern dry unit scale effort smooth jazz weasel alcohol"
let wallet = Wallet.fromMnemonic(mnemonic)
const provider = new JsonRpcProvider("https://rpc.ankr.com/eth");
wallet = wallet.connect(provider)
console.log(wallet.address)
const space = 'pistachiodao.eth'; // the space to vote in
const proposal = '0x38c654c0f81b63ea1839ec3b221fad6ecba474aa0c4e8b4e8bc957f70100e753';
const client = new snapshot.Client712('https://hub.snapshot.org');
(async () => {
try {
const receipt = await client.vote(wallet, wallet.address, {
space,
proposal,
type: 'basic',
choice: 1,
reason: 'I like this proposal',
app: 'script'
});
console.log(receipt);
} catch (error) {
console.log(error)
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment