Created
April 24, 2024 17:13
-
-
Save ChaituVR/db9f78a2f2a7e8347843a6a83393b032 to your computer and use it in GitHub Desktop.
Snapshot vote with nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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