-
Notifications
You must be signed in to change notification settings - Fork 35
Smart Contracts
This page will talk about working with the Fairmint smart contracts directly.
WIP - info on this page is NOT complete yet, check back soon.
Fairmint has a collection of smart contracts, centered around the DecentralizedAutonomousTrust
or "DAT" for short.
- 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
andsell
. - 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
andtransfer
.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).
- 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).
The following explains the process to launch your own c-org.
- 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.
TODO
- BigMath: swap
- Whitelist: swap or upgrade
- DAT: upgrade
- All functions from the https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md, including the optional metadata.
-
transfer
andtransferFrom
reach out to the Whitelist contract to approve the action
-
- Both events from the https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md.