Skip to content

Smart Contracts

Hardly Difficult edited this page Oct 15, 2019 · 9 revisions

This page will talk about working with the Fairmint smart contracts directly.

WIP - info on this page is NOT complete yet, check back soon.

Intro

Fairmint has a collection of smart contracts, centered around the DecentralizedAutonomousTrust or "DAT" for short.

Contracts

  • DecentralizedAutonomousTrust: the primary contract tracking user balances and the org's buyback reserve.

    This contract acts like a standard ERC-20 token with additional features such as buy and sell.

  • Proxy (optional): an upgradable proxy contract by OpenZeppelin

    This contract allows the proxy owner to upgrade the contract's implementation. Once the contract is final and stable the owner may choose to revokeOwnership, removing the possibility of future changes.

  • ProxyAdmin (optional): a contract by OpenZeppelin to manage ownership for Proxy contracts

    Normally the account which owns the Proxy cannot call standard methods on that contract. This works around that limitation by adding another layer. All calls will work as expected, and when a proxy change is required you simply make the change via this contract (owner account calls ProxyAdmin which forwards the request to the Proxy).

  • Whitelist (optional): authorize user actions including buy, sell and transfer.

    This contract helps the org meet any compliance requirements, such as freezing funds for a period of time after purchase. We have an implementation you could use or adapt to your specific requirements. If no Whitelist contract is specified than everything works without requiring authorization.

  • BigMath: a library supporting the DAT contract, enabling us to work with very large numbers.

    This library is separate from the DAT contract in order to save space. It's an implementation detail and you should never need to interact with it directly (we just need to set the address on deployment).

Actors

  • ProxyAdmin: the address which has permission to change the contract implementation. This may apply to the DAT contract and/or the Whitelist contract.
  • Control: the address which has permissions to modify certain variables in the DAT contract.
  • Beneficiary: the address of the beneficiary organization to receive investments generated by the DAT.
  • FeeCollector: the address which receives any fees collected by the DAT.
  • Investor: any account which interacts with the DAT. Typically requires approval in the Whitelist contract before they can receive tokens (via buy or transfer).

Process

The following explains the process to launch your own c-org.

Deploy

  • Deploy proxy admin
  • Deploy BigMath
  • Deploy DAT template
  • Deploy DAT proxy
  • Call DAT initialize
  • Deploy whitelist template
  • Deploy whitelist
  • Call whitelist initialize
  • Call whitelist approve for team accounts (e.g. control/beneficiary)

Once the contracts have been deployed, you should immediately call updateConfig as explained below in order to override default values as appropriate.

Configure

TODO

Upgrade

  • BigMath: swap
  • Whitelist: swap or upgrade
  • DAT: upgrade

Functions

DAT

Whitelist

Proxy Admin

Events

DAT

ERC-20 token currency events (if applicable)

Whitelist events (if applicable)