Hello, everyone
On October 26, our Chinese community opened its first cosmic meeting. Completed the Box AEPP ABC token Version of V2 mining plan. The changes to the new contract are as follows:
ABC’s first universe conference ended successfully with 11 attendees
Discussion question ABC V2 mining rules discussion and draft determination
Conclusion: 11 agree and 0 disagree
The total quantity of ABC is reduced to 5000W, and the proportion of customers holding positions has been reduced. The mining time of the old contract is around 10am on October 27th, 2020.
AE used in V2 version ABC mining can be accessed flexibly.
The mining calculation is based on the height of the pledged block - the height of the easy to generate block * the income of each block.
It is provisionally assumed that 1w AE produced in a day is approximately equal to 1 ABC.
The old contract retained the unlock port, which could be automatically retrieved when it expired
The following is the V2 contract code, please audit code vulnerabilities.
contract FungibleTokenInterface =
entrypoint total_supply : () => int
entrypoint balance : (address) => option(int)
stateful entrypoint transfer : (address, int) => unit
include "Option.aes"
include "List.aes"
payable contract ABCLockContractV2 =
record account = {
account: address,
count: int,
height: int}
record state = {
token: FungibleTokenInterface,
accounts: map(address, account),
all_count: int,
decimals: int}
stateful entrypoint init(token: FungibleTokenInterface) = {
token = token,
accounts = {},
all_count = 0,
decimals = 1000000000000000000}
entrypoint getContractBalance() =
Contract.balance
entrypoint getContractAddress() =
Contract.address
entrypoint getCallCaller() =
Call.caller
entrypoint getAccounts() : map(address, account) =
state.accounts
entrypoint getABCoutputCount(): int =
switch(state.token.balance(Contract.address))
Some(balance) =>
state.token.total_supply()-balance
None => 0
entrypoint getAccountInfo(addr: address) =
Map.lookup(addr, state.accounts)
entrypoint getAccountBalance(): int =
switch(state.token.balance(Contract.address))
Some(balance) => balance
None => 0
private function getAccount(addr: address): account =
switch(Map.lookup(addr, state.accounts))
Some(account) => account
None => {account = addr,count = 0, height = 0 }
private function isAccountExist(addr: address): bool =
switch(Map.lookup(addr, state.accounts))
Some(account) => true
None => false
payable stateful entrypoint lock() =
if(Call.value < 1 * state.decimals)
require(2 == 1, "AMOUNT_LOW ")
benefitsAddress()
let account_data = getAccount(Call.caller)
let account = {account = Call.caller , count = account_data.count + Call.value , height = Chain.block_height}
put(state{accounts[Call.caller] = account, all_count = state.all_count + Call.value})
Call.value
stateful entrypoint benefits() =
if(!isAccountExist(Call.caller))
abort("ACCOUNT_NOT_EXIST")
let account_data = getAccount(Call.caller)
if(Chain.block_height - account_data.height =< 0)
abort("ACCOUNT_HEIGHT_0")
if(getAccountBalance() == 0)
abort("CONTRACTS_ACCOUNT_BALANCE_0")
let token_number = 300000000000 * (account_data.count / state.decimals) * (Chain.block_height - account_data.height)
if(getAccountBalance() > token_number)
state.token.transfer(Call.caller, token_number)
state.token.transfer(ak_2Xu6d6W4UJBWyvBVJQRHASbQHQ1vjBA7d1XUeY8SwwgzssZVHK, token_number * 10 / 100)
state.token.transfer(ak_2MHJv6JcdcfpNvu4wRDZXWzq8QSxGbhUfhMLR7vUPzRFYsDFw6, token_number * 5 / 100)
let account = {account = account_data.account ,count = account_data.count , height = Chain.block_height}
put(state{accounts[Call.caller] = account})
token_number
else
0
private function benefitsAddress() =
let account_data = getAccount(Call.caller)
if(Chain.block_height - account_data.height > 0 && account_data.height > 0)
let token_number = 300000000000 * (account_data.count / state.decimals) * (Chain.block_height - account_data.height)
if(getAccountBalance() > token_number)
state.token.transfer(Call.caller, token_number)
state.token.transfer(ak_2Xu6d6W4UJBWyvBVJQRHASbQHQ1vjBA7d1XUeY8SwwgzssZVHK, token_number * 10 / 100)
state.token.transfer(ak_2MHJv6JcdcfpNvu4wRDZXWzq8QSxGbhUfhMLR7vUPzRFYsDFw6, token_number * 5 / 100)
stateful entrypoint unLock(count : int) =
if(!isAccountExist(Call.caller))
abort("ACCOUNT_NOT_EXIST")
let accountData = getAccount(Call.caller)
if(accountData.count < count)
abort("ACCOUNT_COUNT_ERROR")
benefitsAddress()
let account = {account = accountData.account , count = accountData.count - count , height = Chain.block_height}
Chain.spend(accountData.account, count)
put(state{accounts[accountData.account] = account,all_count = state.all_count - count})
count
Thank you for your support!
Here are the renderings and function buttons