Pragmatic Hodlings contracts allows any organization to distribute it's tokens to all members according to their seniority.
PragmaticHodlings
- main contract with business logic for token distributionMembersBookLib
- library used by main contract for storing members dataTransferableToken
- token contract interface, compatible with Pragmatic HodlingsTestToken
- token contract based on ERC20 interface, used in test
Check out this project on Github Pages
It is highly recommended to use Multisig and/or DAO contracts as owner of Pragmatic Hodlings contract. That approach will be more transparent and will make actions to be less dependent on organization leaders.
To transfer ownership from deployer call transferOwnership
function passing an address
of new owner.
Owner of contract is allowed to add (no duplicates) and remove members. Each members is
described by it's ETH address and timestamp related to joining to organization time.
Member data are stored in array of Member
structures.
struct Member {
address account;
uint64 joinDate;
}
When owner is calling settleToken
function, then available token amount is shared between all members
existing in MembersBook
. Member's share size is directly related to member's seniority, and is
calculated from the following formula:
where is shared amount, is member seniority, is member index and is member count
The chart presented below perfectly shows how token shares differ in time and how each member share depends on it's seniority and total members count.
It is important to notice that all shares are approaching in time to , but they will probably never get there. It is a fair enough way to distribute tokens because the oldest member always get biggest share but also newer members have a chance to get significant share.
After running several tests of gas used by settleToken
function we came up with some conclusions. Test were done for Zeppelin ERC20 token implementation, test accounts have never owned tokens, and members count on contract was increasing up to 100.
First of all settlement gas cost increase each time we add new member by average 33 000 gas. Furthermore a block has a gas limit which is 8 000 000 for now.
If we do the math we get maximum members count for a contract which is 242.
8 000 000 / 33 000 ~ 242
Warning!
In case of emergency when member count at contract exceed possible limit we should consider this solusions:
- Create newer version of contract (e.g. with scenario when member pays for its transfer)
- Move all members to new contract
When submitting a bugfix, write a test that exposes the bug and fails before applying your fix. Submit the test alongside the fix. When submitting a new feature, add tests that cover the feature.
Usage:
npm install
- install dependenciesnpm run compile
- compile *.ts and *.sol filesnpm test
- run testsnpm run format
- format TypeScript filesnpm run lint
- run linter
- Project has been initialized with TypeScript-Truffle generator
- MembersBook library based on SignHash project
Licence: BSD-3-Clause