GithubHelp home page GithubHelp logo

inozemtsev-roman / ton-vote Goto Github PK

View Code? Open in Web Editor NEW

This project forked from orbs-network/ton-vote

1.0 0.0 0.0 40.7 MB

Open source React frontend for ton.vote website - Decentralized DAO Governance for TON

Home Page: https://ton.vote

TypeScript 99.34% HTML 0.66%

ton-vote's Introduction

Open source React frontend for ton.vote website


Background

Our team is working on an open no code governance platform for TON, similar to snapshot.org on EVM.

This system will support governance proposals and voting using native coins (TON coin), jettons or NTFs, with programmable strategies. For example, NFT voting weights can factor rarity if that's what a DAO wants to do.

The full system is still WIP and we are working on adding more features like custom strategies and support to different voting systems.

Properties of this version

  • Voting is done on-chain and costs gas. The future system will also allow gasless voting through off-chain signatures.

  • Votes can be weighted by TON coin balance, Jetton or NFT holdings. Results are calculated in regards to a historic snapshot of the balances that is pre-defined in the proposal. This helps prevent users from manipulating the vote by purchasing/borrowing tokens for the sake of the vote only. This also makes sure that every token can only be used by a single voter.

  • Counting of the votes occurs client-side. We can't tally the votes on-chain since a contract cannot read historic account state. By counting the votes client-side we still reach a pretty good degree of trustlessness. Everyone can be convinced on their own machine that the result is correct. This is a similar trade-off as done on snapshot.org which is the most popular DAO voting platform today.

How can you vote?

To vote, make sure that your TON coin balance was not zero on the snapshot date. Voting will require sending a transaction on mainnet and this will cost very little gas. You will have to send the transaction from the same wallet that held your TON coin balance on the snapshot date.

There are many wallets on TON, we made sure that you can use any of them and that the voting process is as frictionless as possible. Here are some different alternatives for voting:

  1. Use the client in https://ton.vote which supports TonHub, TonKeeper and OpenMask (via TonConnect2)

  2. Transfer 0.01 TON manually to the proposal's contract address and add a comment with your vote - yes or no or abstain. The proposal's address is available in the client on the proposal page under the information section.

  3. Open the relevant ton:// deep link with a supporting wallet. This is the general format (replace proposal-address with the relevant proposal address and your-vote with your vote - yes, no or abstain): ton://transfer/{proposal-address}?amount=10000000&text={your-vote}. For example:

    • yes - ton://transfer/EQCVy5bEWLQZrh5PYb1uP3FSO7xt4Kobyn4T9pGy2c5-i-GS?amount=10000000&text=yes
    • no - ton://transfer/EQCVy5bEWLQZrh5PYb1uP3FSO7xt4Kobyn4T9pGy2c5-i-GS?amount=10000000&text=no
    • abstain - ton://transfer/EQCVy5bEWLQZrh5PYb1uP3FSO7xt4Kobyn4T9pGy2c5-i-GS?amount=10000000&text=abstain

After voting, you can open the client in https://ton.vote to see your vote counted. It will appear in the top of the recent votes list.

Note that we only allow users to use their own voting assets. This means we do not count votes from known custodial services such as exchanges, custodial wallets, etc. You can check the list of blacklisted addresses here. If you are an owner of an address from this list and want to know how to vote, you can contact us via Telegram: https://t.me/TONVoteSupportGroup.

How can you verify the results?

We took great care to make sure the voting process and calculation is decentralized and trustless. You can verify the results by yourself and you are not required to trust anyone in the process.

  1. Votes are sent as on-chain transactions to a smart contract on mainnet. The smart contract address can be obtained from the proposal page on the information section.

  2. You can open the proposal contract in an explorer and see all transactions sent to it with their votes as comments. You can also use ton verifier to see the contract code since it is verified, just go to https://verifier.ton.org and enter the propoal address. The source includes parameters of the proposal like start and end dates, snapshot date, voting strategy and more.

  3. The browser app that displays the results is open source and served from GitHub Pages on this repo. It uses a cache server only for better user experience but it can also work without the cache server and read all data from the chain in order to calculate the results.

  4. When you press the "Verify" button next to the results, your browser will download all the votes sent to the contract by using TON RPC API. Your browser will query the balance of each voter in the snapshot time using TON RPC API. Your browser will then combine the results by applying the weight for each vote as the balance. This entire process happens client-side making it 100% trustless.

  5. To alleviate any concerns that the TON RPC API gateways might influence the results somehow, the client also allows you to provide your own RPC endpoints. You can find this option under "Settings". You are welcome to rely on any RPC endpoint you trust or run your own endpoint to be 100% trustless.

  6. When Ethereum, which is considered successfully decentralized by the industry, held similar votes community-wide, the process was similar. So we are in good company.

Walkthrough of the implementation

  • Every DAO needs to open a DAO space before it can submit new proposals. The DAO as well as the prposals are contracts on the TON blockchain. you can see the contracts implementations here.

  • The proposal contract is a very simple Tact contract to be a destination for votes. Voters vote with a comment so they can vote even without a special client. Contract holds parameters of the proposal such as start, end and snapshot timestamps, voting system and strategy, title ansd description and more.

  • The proposal owners can update the proposal only until the start timestamp, after this time it is immutable and can not be changed. We use this mechanism to avoid influencing the proposal results but still allowing owners to make some changes to the proposal before it starts.

  • Vote calculation logic - The vote calculation happens in JavaScript. It downloads all the votes using HTTP v2 API (transactions sent to the contract). Each vote is weighted according to the holdings of the voter in the snapshot timestamp, which is read using HTTP v4 API. Most recent vote takes.

  • App UI - The product is heavily inspired by snapshot.org proposal page. Users see the current status of the vote and calculate the result client-side. Users can vote using TON Connect 2 and support for other wallets like TonHub, although users can also vote by sending a comment to the contract so no client is mandatory. Users can change in the settings the HTTP v2 and HTTP v4 endpoints in order to be 100% trustless (in case they fear that the RPC servers don't give them the correct data).

How to get verified as a DAO space?

The UI displays a blue checkmark next to verified DAOs, indicating that their ownership of the domain has been verified. Verified DAO spaces on ton.vote can be trusted as they accurately represent the claimed domain. When a DAO is verified, its website is featured in the DAO space on the homepage of ton.vote.

To verify your DAO space on ton.vote, please follow these steps:

  1. Upload a txt file to your website.
  2. Name the file ton-vote.txt.
  3. Place your DAO address inside the txt file.
  4. Ensure the file is accessible through a URL following this format: https://yourdomain.com/ton-vote.txt. (Replace "yourdomain.com" with the actual domain of your website)

You can find your Dao address on the Dao page after creating the DAO. By completing these steps, your DAO will be marked as verified by ton.vote.

How to make test proposals?

We have built a dedicated platform for testing proposals and its available here. It is advisable to refrain from spamming your DAO with testing proposals. If you wish to create a test proposal, you can utilize dev.ton.vote. Just create a new DAO and create as many testing proposals as needed.

We have created a dedicated platform at dev.ton.vote specifically for testing proposals. To maintain the integrity of your DAO, we kindly request that you refrain from spamming it with testing proposals. Instead, you can leverage the dev.ton.vote platform to create a new DAO and generate as many testing proposals as you require.

Live demo

The platform is live and deployed to mainnet. The client is at https://ton.vote - you can go there and play with the system. There are missing features that are still WIP. You can submit additional feedback as issues or directly to the Telegram support group.

Why not calculate results on-chain?

There are ideas in the community on how to implement an on-chain DAO. Most proposals have to do with Jettons, not with TON coin itself. These proposals also generally prevent or limit tokens from being transferred during the vote so they would not be used twice. We believe that such limitations will decrease participation in the vote and prevent some voices from being heard. Even with democratic elections that happen once every 4 years, voter turn-out is always too low. The off-chain calculation method is as secure (nobody can create widespread result fraud) and by relying on a historic balance snapshot, there is no need to limit any of the voters in any way.

Supported Strategies

We support the following strategies:

  1. Weighted Balance: in this strategy, we consider the voter's balance on the snapshot date (which can be found on the proposal page in the info section). The more coins a voter holds, the greater their voting power. While this approach is logical as it grants more influence to those with larger coin holdings, it can also lead to increased influence for large-scale investors, often referred to as whales. This strategy can be applied to TON coins, Jetton, or NFTs. For NFTs, we count the number of NFTs held by the voter, while for Jetton, we consider the Jetton balance. You also have the option of allowing validators to take part in this type of vote, see Validators Vote section for more details.

  2. One Wallet, One Vote: This strategy grants equal voting power to all participants, regardless of the number of coins they hold. Each holder receives precisely one voting power. This strategy aims to address the bias introduced by the Weighted Balance strategy, ensuring more fairness and equal representation among voters.

Validators Vote

In certain situations, you may consider allowing validators to be part of the proposal process. Validators are responsible for maintaining the network and usually stake a significant amount of TONs in the elector contract, this is a well known concept in POS blockchain where the validators stake some tokens and get rewards for maintaining the network or get punished for bad behavior.

Validators typically have a substantial amount of tokens held in the elector contract, a dedicated contract. This could sometimes prevent them from participating in an active weighted balance vote. However, ton.vote enables validators to partake in ongoing proposals using their operational wallets in mytonctrl. Validators can leverage the operational wallet that oversees the staking wallet (like a single nominator, nominator pool or any basic wallet) and can cast their vote by sending a certain amount of coins accompanied by a comment.

For instance, using mytonctrl, the command mg validator_wallet_001 EQAiqphPtZ2jLyzqrcfVrhBZfarghWKpkt0fSfALsqRbofQ7 0.01 -C yes will transmit 0.01 TON from validator_wallet_001 to the contract at address EQAiqphPtZ2jLyzqrcfVrhBZfarghWKpkt0fSfALsqRbofQ7 with the commentary as yes.

The generic command structure would be: mg wallet-name contract-address 0.01 -C your-vote.

License

MIT

ton-vote's People

Contributors

amihaz avatar denis-orbs avatar nikitindenis1 avatar shaharyakir avatar talkol avatar tsivarev avatar

Stargazers

 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.