@gooddollar/goodcontracts

中文文档
2.6.6发布于 2022/10/27MIT近 30 天下载 2785

GoodDollar Contracts

原始使用文档
文档目录24 节
  1. Installation
  2. Usage
  3. Setup GoodDollar
  4. Deploy GoodDollar
  5. Deploy UBI
  6. Deploy SignUpBonus
  7. Deploy OneTimePayment
  8. Prerequisites
  9. Files
  10. GoodDollar Economic Model and Contracts
  11. GoodDollar Design Overview
  12. Implementation of a Decentralized Autonomous UBI system (Th…
  13. Representation of Value with an ERC20 Token (The GoodDollar)
  14. Achieving Tranaction speed with a Bridge Contract and Sidec…
  15. GoodDollar
  16. DAUCreator
  17. Controller
  18. Avatar
  19. Schemes
  20. Supporting Contracts
  21. Sign-up bonus
  22. OneTimePayments
  23. Identity
  24. Community

GoodDollar - GoodContracts

CircleCI Coverage Status License: MIT Gitter

Contributing

Welcome to the GoodDollar repository!

Everyone is welcome: Developers, designers, and entrepreneurs with a passion for decentralized technologies and a vision to build a new world that has equality, security, inclusivity, and innovation as its cornerstones. Refer to GoodDocs for further information.

Try GoodDollar

Installation

Clone the repository:

git clone https://github.com/GoodDollar/GoodContracts.git

Install packages:

npm install

Usage

To test the library and setup the environment, issue the following command:

  npm run test

Setup GoodDollar

  1. Go to the GoodContracts repository:
cd GoodContracts
  1. Create a .env file:
cp .env.example .env
  1. Fill in the required information. see Configuration for descriptions.

Deploy GoodDollar

The GoodContracts DAO can be deployed in two ways:

full - All contracts are deployed to the network given in .env. This is done by running npm run deploy:full

light - The DAO contracts and GoodDollar is deployed. OneTimePayments, UBI and SignUpBonus are not. This is done by running npm run deploy

Deploy UBI

New UBI schemes are deployed by calling

npm run deploy:ubi

This will deploy a UBI contract with the parameters given in the migration script, propose it as a new scheme vote for it and start the contract if enough votes are given.

Deploy SignUpBonus

New SignUpBonus schemes are deployed by calling

npm run deploy:signup

This will deploy a SignUpBonus contract with the parameters given in the migration script, propose it as a new scheme vote for it and start the contract if enough votes are given.

Deploy OneTimePayment

New OneTimePayments schemes are deployed by calling

npm run deploy:otp

This will deploy a OneTimePayment contract with the parameters given in the migration script, propose it as a new scheme vote for it and start the contract if enough votes are given.

Prerequisites

You need to have node installed. This repository has only been tested on UNIX-derived systems.

Files

PathDescription
contracts/All the solidity files making up the implementation
contracts/tokenContains the GoodDollar implementation
contracts/token/ERC677ERC677 implementation
contracts/identityDefines the identity implementation, i.e. adding claimers and blacklisting
contracts/daoContains the daocreator for creating DAOs
contracts/dao/schemesContains different schemes that can be deployed, registered and used within the DAO
contracts/mocksContracts used specifically for testing purposes
test/Contains testing code
scripts/ Specific scripts for testing and coverage

Learn about GoodDollar

The GoodDollar mission is reducing wealth inquality by building a new, global, open-source cryptocurrency for distributing money according to the principles of universal basic income (UBI).

To learn more about the reasoning behind the GoodDollar Experiment, please read the Position Paper.

This implementation of the GoodDollar contract system contains forked and modified from the DAOstack repo. We recommend anyone interested in learning about DAOs to [read and contribute] https://github.com/daostack

In this document, we present the on going development efforts and specification of the extended design of the GoodDollar contract system. In section one, we introduce the key concepts of the contract system. In section two, we introduce the individual contracts available in this repo.

This text introduces the core components of the GoodDollar contract system and is intended as a brief overview of the current status of development. This specification is subject to ongoing development and frequent review. This text may not reflect the most recent commit.

GoodDollar Economic Model and Contracts

Staking Model

GoodDollar Design Overview

In the Table presented below, we provide an overview of the extended design of the GoodDollar contract system suggested for this specification.

overview

Figure 1: Design overview of the GoodContracts system

GoodDollar Contract System: The Key Concepts

The GoodDollar contract system is an implementation of a decentralized autonomous organization. The design presented in this document is an iterative policy framework through which users can engage in the collective decision making on the allocation and inflation schedule of a new asset-class: The GoodDollar.

Users suggest, advocate and vote for policy proposals in the form of 'schemes'. A scheme is a user-defined script, containing the logic by which the distribution of community funds is executed at specified intervals.

Once implemented, a scheme will run for a given period of time and subsequently deprecate, at which point the community will vote on either extending or replacing the extant scheme.

Voting power is defined by 'reputation points', a value assigned to all registered addresses. Reputation points can be distributed by any arbitrary logic and perform any arbitrary decision making function in the system. In this implementation, reputation points denote a weighted distribution in which one reputation point equals one vote in a binary choice evaluated by the absolute majority criterion.

The voting logic itself is also implemented as a scheme and is, just as the distribution policy, subject to change by a absolute majority voting.

This concept facilitates the abstract notion of decentralized decision-making in distributed systems of autonomous agents, as the contract system assimilates the political decision-making process through which fiscal policy is implemented in conventional parlimentary systems. Nevertheless, here all participants can attain voting power by virtue of their participation and engagement with the system.

In the following months, we will present more cohesive work on the topic of voting power and decentralized decision-making in decentralized systems. Please stay in touch by following this repo or keep an eye out on social media.

The contract system for the current release, comprises four main components:

Implementation of a Decentralized Autonomous UBI system (The DAU)

The DAU is a decentralized decision-making and resource distribution mechanism. It contains four elements:

  • Schemes - A "scheme" is a 'wrapper' enacting a given policy or functionality in the GoodDollar contract system. Schemes are deployed by users and elected by the DAU contract through 'reputation voting' (see below). The UBI distribution policy, the one-time payment link policy, the sign-up bonus policy, and the identity contract are all implemented as 'schemes' and can be reiterated and redeployed by the GoodDollar community.

  • Reputation points - Reputation points are awarded to user accounts by the DAU. The reputation distribution function will be based on contributions to the system, as defined by the GoodDollar community. Reputation is non-transferable and (re)distributed by the DAU.

  • Voting Mechanism - Schemes are approved or rejected through voting. Rules can be implemented for any arbritary voting process and logic. In this initial implementation, voting follows the standard absolute majority criterion. In this implementation, a single reputation point will denote a single vote in the scheme selection process.

  • Global Constraints - Global constraints are limitations the DAUs actions. When executing a scheme, the controller component checks the constraints to see if a given action violates them, and blocks the execution if it does.

Representation of Value with an ERC20 Token (The GoodDollar)

The GoodDollar is a mintable, burnable and ERC20 compatible token. The GoodDollar token can collect an adjustable fee stored in a reserve, whenever a transaction is made.

Achieving Tranaction speed with a Bridge Contract and Sidechain

The bridge contract is an interoperability protocol that allows users to easily and safely transfer digital assets between two blockchains. Similar to an atomic swap operation, assets are locked in one network while representative assets are minted in the other one, and when the process is reversed the representative assets are burned and the locked assets released. The GoodDollar system is currently implemented on a sidechain connected through the Bridge Contract. For this implementation, we deploy on the fuse network: https://github.com/ColuLocalNetwork/fuse-network

Contract Overview

In the Table presented below, we provide a simple overview of the GoodDollar contract and scheme taxonomy. Only the most fundemental schemes are included in the list below.

nameDescription
GoodDollarERC20 Token that collects fees in every transfer. Native token of the system
DaoCreatorCreates a single GoodDollar organization with an array of founders able to vote for schemes.
ControllerThe central entity of the DAO which connects the Avatar and gives permission to the other contracts.
AvatarA contract that receives the fee, stores it and communicates with the outer world
UBIThe Universal Basic Income calculating and processing contract scheme.
SignUpBonusThe sign-up bonus handling contract.
OneTimePaymentsThe one-time payment contract.
IdentityThe contract defines who is eligible to claim the tokens and counts the total number of people who signed up for it.

GoodDollar

The GoodDollar token is a mintable, burnable and ERC20 compatible token. In this implementation, the token collects an adjustable fee.

Below we list the three main functions, adopted from the standard contract:

nameDescriptionWorking Priciple
transfer(to, value) / transferFrom(from, to, value)Gives the system the ability to collect fees.Whenever transfer or transferFrom is called with a given value, processFees is called with said value, transferring the transactional fees (set by the DAO at any given time, by a specific scheme) to the feeRecipient and returning the new value to be transferred along.
approve(spender, value)Gives a delegate the right to spend a certain amount of tokens of a delegator. The delegators retain the ownership of the tokens until they are spent.no peculiarities
balanceOf(user)It allows the system to know the G$ balance of a specific address.no peculiarities

Below, we display the GoodDollar transfer function sequence diagram, highlighting the details of the process.

transfer

Figure 2: Transfer function. Checks identity, then sends fees to avatar, which returns the new transfer value and sends it to the receiver.

DAUCreator

The DAUCreator contract is responsible for creating the DAU in a single transaction. When creating a DAU, a Token (The GoodDollar token) and reputation are created, which are then used to create the avatar. The founders specified in the creation are then granted their respective tokens and reputation. The controller is then created and given ownership of the GoodDollar, Reputation and Avatar. The caller of the dao creation transaction is then allowed to register an array of initial schemes.

Controller

The Controller is the 'owner' of the DAO. It gives permission to other schemes, enforces adherence to global constraints, regulate the reputation points and most importantly it connects to the Avatar.

Avatar

The Avatar is the outer facing part of the DAO system, which interacts with the other DAOs and contracts. The three main functions of the Avatar are to:

  • Communicate with other contracts
  • Receive the transaction fees
  • Store the fees and also other tokens (i.e., Ether)

Schemes

A UBI scheme can be created by anyone and submitted to the GoodDollar Community. A UBI scheme is proposed and voted upon by users. Once a UBI scheme is implemented, the Controller transfers the alotted amounts from the reserves.

When the UBI scheme is created, the author defines start and end periods. A bool, isActive, is set to false, making the policy ‘dormant’ until start() is called. Once start() is called the UBI is active and the claiming process begins.

The Reserve (Avatar) sends all its funds to the UBI contract, and the GoodDollar to mint, indicated in the constructor, is minted to and sent to the contract.

UBIstates

Figure 3: The three states the UBI contract moves through

Then, the distribution ratio is calculated and isActive is set to true, allowing users registered as claimers (before the start period) to claim UBI. After a successfull claim is registered, the users claimin status is updated in order to prevent multiple claims from the same address.

UBIsequence

Figure 4: UBI claiming sequence diagram

Finally, the end() function is called, terminating the contract. This can only be done after the period has been exceeded. A deprecated scheme transfers all remaining funds back to the reserve.

Supporting Contracts

A number of contracts are implemented to support the launch of the GoodDollar system. These contracts are implemented as 'schemes' and are subject to reputation voting by the community.

Sign-up bonus

The sign-up bonus scheme allows administrators to award tokens up to a given maximum to users for inviting others.

OneTimePayments

The OneTimePayments scheme is able to receive funds and keep them stored under a hashed code, allowing users to send funds to unregistered users that can be claimed once they have been registered.

Identity

The Identity scheme manages the list of verified user addresses and blacklisted addresses.

Community

Below you can find a comprehensive list of useful links.

版本与发布记录

@gooddollar/goodcontracts 共发布 77 个版本,首次发布于 2019/01/21;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.6.6latest2022/10/274 年前
2.6.42022/09/134 年前
2.6.32022/09/124 年前
2.6.22021/10/065 年前
2.6.12021/02/075 年前
2.6.02021/02/025 年前

其他发布通道:beta → 1.0.0-beta.1。

关于 @gooddollar/goodcontracts 的常见问题

@gooddollar/goodcontracts 是什么?

GoodDollar Contracts

如何安装 @gooddollar/goodcontracts?

在项目目录运行 npm install @gooddollar/goodcontracts,或使用 pnpm add / yarn add / bun add。

@gooddollar/goodcontracts 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/gooddollar__goodcontracts 是否存在。

@gooddollar/goodcontracts 可以商用吗?

@gooddollar/goodcontracts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gooddollar/goodcontracts 的下载量有多少?

根据 npm 官方下载统计,@gooddollar/goodcontracts 在 2026/10/17 – 2026/11/15 这 30 天内被下载 2,785 次,日均约 93 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gooddollar/goodcontracts 还在维护吗?

最新版本 2.6.6 发布于 2022/10/27(4 年前);至今共发布 77 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/01/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。