dvote-polygon is a typescript library integrated into the [polygon] (https://polygon.technology/) network.
This library is tested on the polygon Mumbai test network using quicknode provider.
This library is tested on Ganache, which is a personal Ethereum blockchain.
npm i dvote-polygon
PRIVATE_KEY = YOUR_PRIVATE_KEY_OF_CRYPTO_WALLET_ADDRESS
import {Dvote} from "dvote-polygon";
second parameter is false by default and it could be true if you want to deploy new contract! you can leave it blank if you want to use previous contract.
const endpointUrl = "http://127.0.0.1:8545" // your provider
const dv = new Dvote(endpointUrl, renewContract) // create new instance
let abi = dv.compile().abi()
let bytecode = dv.compile().bytecode()
dv.deploy(abi, bytecode).then(data=>{
result = data;
})
let ballotName = "EBAY-SCORES"
let voteOptions = ["Perfect", "Good", "Bad", "Worst"]
dv.createVote(voteName, voteOptions).then(data=>{
result = data;
})
let fromAddress = "any User Wallet Address"
let ballotName = "EBAY"
let voteOption = "Perfect"
dv.addVote(voteName, voteOption, fromAddress).then(data=>{
result = data;
})
let fromAddress = "any User Wallet Address"
let ballotName = "EBAY"
let newOption = "Good"
dv.changeVote(ballotName, newOption, fromAddress).then((data:any)=>{
result = data;
})
let ballotName = "EBAY"
dv.voteResult(ballotName).then((data:any)=>{
result = data;
})
If you are interested in contributing to this project, I will be very glad ^__^
MIT