Skip to content

tablelandnetwork/example-voter

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

About

A simple voting mechanism built with Tableland

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •