Git Product home page Git Product logo

example-voter's Introduction

example-voter

Review License Version standard-readme compliant

A simple voting mechanism built with Tableland

Table of Contents

Background

example-voter is an experimental voting system built on Tableland. You can use this tool to ask y/n questions of an entire ERC721 collection. Only holders of the token will be able to answer your questions. Use this as an example of how you might build an all-in-one Snapshot like system with Tableland. Anyone can create questions and query results from the Tableland network.

Usage

example-voter is deployed to Optimism Goerli. Grab some Goerli, bridge to Optimism, and start asking questions :)

> voter --help

voter <command>

Commands:
  voter init [format, path, yes]  Create config file
  voter ask <token> <question>    Ask holders of an ERC721 collection a
                                  question.
  voter answer                    Answer a question. Only shows questions you
                                  can answer based on NFT holdings. You can only
                                  answer a question once.
  voter questions                 List questions you can answer based on NFT
                                  holdings.
  voter answers                   List answers you have given.

Options:
      --help         Show help                                         [boolean]
      --version      Show version number                               [boolean]
  -k, --privateKey   Private key string                                 [string]
  -c, --chain        The EVM chain to target[string] [default: "polygon-mumbai"]
  -p, --providerUrl  JSON RPC API provider URL. (e.g.,
                     https://eth-rinkeby.alchemyapi.io/v2/123abc123a...)[string]

Install

The example-voter package isn't published to NPM, but you can build the CLI locally:

git clone https://github.com/tablelandnetwork/example-voter.git
cd example-voter
npm install
npm run build
npm install -g .
voter --help

Config

voter uses cosmiconfig for configuration file support. This means you can configure voter via (in order of precedence):

  • A .voterrc.json, .voterrc.yml, or .voterrc.yaml file.
  • A .voterrc file written in JSON or YAML.
  • A "voter" key in a local package.json file.

The configuration file will be resolved starting from the current working directory, and searching up the file tree until a config file is (or isn’t) found.

voter intentionally doesn’t support any kind of global configuration. This is to make sure that when a project is copied to another computer, voter's behavior stays the same. Otherwise, voter wouldn’t be able to guarantee that everybody in a team uses the same consistent settings.

The options you can use in the configuration file are the same as the global cli flag options. Additionally, all of these configuration values can be overriden via environement variables (prefixed with VOTER_), or via a local .env file. See .env.example for an example.

A configuration file can also be bootstrapped using the voter init command. This will provide an interactive prompt to setup a config file (you can skip the interactive prompts by using the --yes flag). Global cli flags can be used in combination with the init command to skip specific questions. For example voter init --chain "optimism-goerli" will skip the question about default chain, and use optimism-goerli in the output config file.

Development

Get started with installing and building the project:

npm install
npm run build

Contributing

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

The Unlicense

example-voter's People

Contributors

sanderpick avatar joewagner avatar

Watchers

 avatar Aaron Steele avatar cjqf avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.