# circles-contracts

Latest version **2.3.1** (published 2020-10-15) · AGPL license · 0 weekly downloads

## Install

```sh
npm install circles-contracts
pnpm add circles-contracts
yarn add circles-contracts
bun add circles-contracts
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.3.1 |
| Published | 2020-10-15 |
| First published | 2019-08-29 |
| Weekly downloads | 0 |
| License | AGPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 3.3 MB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 78 |
| Maintainers | ana0 |

## Links

- npm: https://www.npmjs.com/package/circles-contracts
- Repository: https://github.com/CirclesUBI/circles-contracts
- Issues: https://github.com/CirclesUBI/circles-contracts/issues
- npm.io page: https://npm.io/package/circles-contracts

## Dependencies (9)

- [bluebird](https://npm.io/package/bluebird.md) ^3.7.1
- [web3-eth-abi](https://npm.io/package/web3-eth-abi.md) ^1.3.0
- [@truffle/error](https://npm.io/package/@truffle/error.md) 0.0.9
- [ethereumjs-abi](https://npm.io/package/ethereumjs-abi.md) ^0.6.8
- [truffle-contract](https://npm.io/package/truffle-contract.md) ^4.0.31
- [@truffle/contract](https://npm.io/package/@truffle/contract.md) ^4.2.21
- [@circles/safe-contracts](https://npm.io/package/@circles/safe-contracts.md) ^1.0.14
- [@openzeppelin/contracts](https://npm.io/package/@openzeppelin/contracts.md) ^3.1.0-solc-0.7
- [truffle-hdwallet-provider](https://npm.io/package/truffle-hdwallet-provider.md) ^1.0.17

## Recent versions

- 2.3.1 (latest) — 2020-10-15
- 2.3.0 — 2020-10-14
- 2.2.0 — 2020-10-14
- 2.1.3 — 2020-09-21
- 2.1.2 — 2020-09-17
- 2.1.1 — 2020-09-15
- 2.1.0 — 2020-09-15
- 1.0.19 — 2020-07-05
- 1.0.18 — 2020-02-15
- 1.0.17 — 2020-02-15
- 1.0.16 — 2020-01-25
- 1.0.15 — 2019-12-17
- 1.0.14 — 2019-11-19
- 1.0.13 — 2019-11-18
- 1.0.12 — 2019-11-18
- … 10 more at https://npm.io/package/circles-contracts/versions

## README

# Circles Contracts 

<p>
  <a href="https://chat.joincircles.net">
    <img src="https://chat.joincircles.net/api/v1/shield.svg?type=online&name=circles%20chat" alt="Chat Server">
  </a>
  <a href="https://opencollective.com/circles">
    <img src="https://opencollective.com/circles/supporters/badge.svg" alt="Backers">
  </a>
  <a href="https://github.com/CirclesUBI/circles-contracts/blob/master/LICENSE">
    <img src="https://img.shields.io/badge/license-APGLv3-orange.svg" alt="License">
  </a>
  <a href="https://travis-ci.org/CirclesUBI/circles-contracts">
    <img src="https://api.travis-ci.com/CirclesUBI/circles-contracts.svg?branch=development" alt="Build Status">
  </a>
  <a href="https://twitter.com/CirclesUBI">
    <img src="https://img.shields.io/twitter/follow/circlesubi.svg?label=follow+circles" alt="Follow Circles">
  </a>
</p>


This is the initial smart contract implementation for the Circles universal basic income platform.

**Note:** This is not yet intended for deployment in a production system.

[Website](http://www.joincircles.net) // [Whitepaper](https://github.com/CirclesUBI/circles-handbook/blob/master/docs/about/whitepaper.md) // [Chat](https://chat.joincircles.net)

## Basic design

There are several components:

### Token

This is derived from standard ERC20 implementations, with two main differences: The balance for the "owner" (UBI receiver) is calculated based on the time elapsed since the contract was created, and there is an "hubTransfer" function that allows trusted transitive exchanges. Tokens belong to the hub that deployed them, and can only transact transitively with tokens from the same hub. Tokens have owners, which can be an external account or any kind of contract - in our deployment, they will be [gnosis safes](https://github.com/gnosis/safe-contracts).

### Hub

This is the location of system-wide variables and the trust graph. It has special permissions on all tokens that were deployed through it and have authorized it to perform transitive exchanges. Hub has an owner, which should at least be a multisig, (in our deployment this will also be a [gnosis safe](https://github.com/gnosis/safe-contracts)) but can in practice be any type of address.

![contract diagram](/assets/ContractDiagram.jpg)

Illustrated here are some of the main available calls:
 - Signup method of the hub deploys a circles token
 - Safe or external account makes trust connections within the hub with the trust method
 - Users send transitive transactions with the hub, which has special permissions on tokens


## Getting started

Requires [node version 12](https://nodejs.org/en/download/)

Clone down this repo and `npm install`

With ganache running (`npm run ganache`), in a new console window, `node_modules/.bin/truffle compile` then `node_modules/.bin/truffle migrate`

**Note:** This is a work in progress and this should be done only for contribution and exploration purposes.

## Testing

Requires [node version 10](https://nodejs.org/en/download/)
`npm test` will re-build the contracts / tests and run all of the tests in the [test](test) directory.

Tests are executed with the help of [Truffle](https://truffleframework.com/docs/truffle/testing/writing-tests-in-javascript) and written in javascript using [Mocha](https://mochajs.org/) with the [Chai assertion library](https://www.chaijs.com/). 

When you run `npm test` a new local blockchain will be started with ganache-cli (unless you already have one running). The contracts will be deployed and the javascript tests will make transactions to this chain.

Helper functions defined in [test/helpers](test/helpers) provides functionality for more complicated tests such as: reading the event log, or checking for an EVM "revert / throw", or changing the blockstamp times.

## License

GNU Affero General Public License v3.0 `AGPL-3.0`

---
_Source: https://npm.io/package/circles-contracts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
