Giter Club home page Giter Club logo

near-public-initiative's Introduction

๐Ÿ™‹ Public initiative voting app

Create an initiative, collect NEAR tokens for it and compete with other initiatives to win and get funded.

Users can vote for public initiatives by attaching NEAR tokens as contributions.

The initiative with the most contributions wins and it's creator receives all the collected funds

๐Ÿ“ฝ DEMO VIDEO

Contract

A simple contract that allows people to collect funds for public initiatives and decide which initiative should be implemented receive all the collected funds.

// ------------------------------------
// contract initialization
// ------------------------------------

/**
 * initialize contract with owner ID and other config data
 *
 * (note: this method is called "constructor" in the singleton contract code)
 */
function init(owner: AccountId, allow_anonymous: bool = true): void

// ------------------------------------
// public methods
// ------------------------------------

/**
 * creates an initiative that users can vote for
 */
function create_initiative(description: string): u32

/**
 * votes for an initiative
 */
function vote(initiative: u32): void

/**
 * lists all votes and contributtions of an initiative
 */
function list_votes(initiative: u32): void

/**
 * lists all votes and contributtions of an initiative
 */
function list_initiatives(): Array<Initiative>

// ------------------------------------
// owner methods
// ------------------------------------
/**
 * selects the winning initiative and transfer all the contributions to the initiative creator
 */
function finalize_voting(): void

Usage

Development

To deploy the contract for development, follow these steps:

  1. clone this repo locally
  2. run yarn to install dependencies
  3. run ./scripts/1.dev-deploy.sh to deploy the contract (this uses near dev-deploy)

Your contract is now ready to use.

To use the contract you can do any of the following:

Public scripts

2.create-initiative.sh    # create an initiative, need to attach NEAR tokens as an initial contribution
3.vote-for-initiative.sh  # vote for an initiative by attaching NEAR tokens
4.finalize-voting.sh      # select the initiative that has the most contributions and transfer to the creator

Owner scripts

o-report.sh             # generate a summary report of the contract state
o-transfer.sh           # transfer received funds to the owner account

Production

It is recommended that you deploy the contract to a subaccount under your MainNet account to make it easier to identify you as the owner

  1. clone this repo locally

  2. run ./scripts/x-deploy.sh to rebuild, deploy and initialize the contract to a target account

    requires the following environment variables

    • NEAR_ENV: Either testnet or mainnet
    • OWNER: The owner of the contract and the parent account. The contract will be deployed to thanks.$OWNER
  3. run ./scripts/x-remove.sh to delete the account

    requires the following environment variables

    • NEAR_ENV: Either testnet or mainnet
    • OWNER: The owner of the contract and the parent account. The contract will be deployed to thanks.$OWNER

near-public-initiative's People

Contributors

amgando avatar tuyakhov avatar

Stargazers

 avatar

Watchers

 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.