For build EOS contracts you need download eosio-cpp 1.7.0 and EOS binaries https://developers.eos.io/manuals/eos/latest/install/install-prebuilt-binaries
Run the build.sh
script in the top directory to build all the contracts.
./build.sh
All .wasm and .abi files will be located in the build/cmkryvesting
directory
./build.sh -t
Unit test will be located in the build/cmkryvesting_tests
directory
After build the wasm you need to create the local wallet to deploy the contract
cleos wallet create --to-console
Import your account's private key for active permissions
cleos wallet import --private-key <PRIVATE_KEY>
Deploy your contract
cleos -u https://ore-staging.openrights.exchange set contract comakeryteam cmkryvesting cmkryvesting.wasm cmkryvesting.abi -p comakeryteam@active
Add the asset
cleos -u https://ore-staging.openrights.exchange push action comakeryteam addaset '{"asset_contract":"eosio.token","asset_symbol":"4,ORE"}' -p comakeryteam@active
You need to add eosio.code permissions to contract and depositors. For example:
cleos set account permission depositaccnt active depositaccnt --add-code
cleos set account permission comakeryteam active comakeryteam --add-code
cleos -u https://ore-staging.openrights.exchange push action comakeryteam addvesting '{"account_id": "<vesting_account>","vesting_period": 1, "vesting_amount":"48000.0000 ORE","cliff_date":"2020-06-01T00:00:00","cliff_weight":"0.25","start_date":"2019-06-01T00:00:00","end_date":"2023-06-01T00:00:00"}' -p comakeryteam@active
cleos -u https://ore-staging.openrights.exchange push action comakeryteam claim '{"vesting_id": 0}' -p <vesting_account>@<permission>
docker-compose up -d
./ignition.sh
The first step runs the local EOS node
The second step runs deployment system contracts
The vesting contract has these features:
Deployable to the EOS, ORE or Telos based blockchain
Reusable for EOS tokens and tokens on Telos blockchains such as ORE token
A single vesting contract handles vesting escrows for multiple people. It is only deployed once.
For each token recipient account an admin can specify:
An admin can pause the vesting on the account.
An admin can cancel the vesting for an account.
An admin can reclaim the unvested token amount.
After vesting or transfer there may be a separate lockup period. Unlike a vesting period, the tokens cannot be reclaimed by the issuer prior to the vesting date.
Once the tokens are fully vested and the lockup period is over the recipient may transfer them wherever they like.
Vestings may have been promised in the past with the vestings contract token allocation configured later. So the calculation of vested and locked tokens should be able to use a start date in the past for vested and locked tokens.
An admin can grant more than one vesting to the same recipient address.
The vesting period defaults to monthly but can be set to monthly, weekly, daily and continuous. Continuous evenly vests the tokens with each verified block timestamp. The vesting occurs on the first moment of the vesting period such as midnight on the first of the month or midnight on the first day of the week, etc.
The smart contract should implement the following or similar functions. Use unsigned ints or ints or make other changes as you see fit during development.
void setToken(tokenAddress or identifier) //sets the token that is managed
void deposit(amount) //deposit tokens into the pool that are available for allocation
void withdraw(amount) //withdraw tokens from the pool that are available for allocation but not allocated
void getUnallocatedBalance() //returns the balance of unallocated tokens
void getAllocatedBalance() // returns the balance of allocated tokens
int getBalance() // returns the balance of allocated and unallocated tokens
void addAdmin(address) // adds an admin who can administrate the contract
void removeAdmin(address) // removes an admin. Does not allow less than 1 admin for the contract.
int createVesting(recipientAddress, amount, startDate, endDate, vestingPeriod=defaultMonthly, lockedUntilDate=defaultNone, cliffDate=defaultNone, cliffTokenAmount=defaultNone) // create a vesting and return the allocationId. Keep in mind that one recipient address can have multiple allocation.
int createAllocation(recipientAddress, amount, lockedUntilDate=defaultNoLockup) // create an allocation and return the allocationId. Keep in mind that one recipient address can have multiple allocations.
void cancelVesting(allocationId, pauseTime=defaultToNow) // cancels the vesting at a vesting time that is not in the past
void pauseVesting(allocationId, pauseTime=defaultToNow) // pauses the vesting at a vesting time that is not in the past
void unpauseVesting(allocationId, pauseTime=defaultToNow) // unpauses the vesting at a vesting time that is not in the past
int transferTokens(amount, recipientAddress) // can only transfer vested and unlocked tokens
int getTransferableBalance(allocationId) // can only transfer vested and unlocked tokens
int getLockedBalance(allocationId)
int getLockedUntilDate(allocationId)
int getUnvestedBalance(allocationId)
??? getAllocationInfo(allocationId) // get summary of information about the allocation including vesting schedule