ERC20Permit extension to pay gas fees by only BLB token.
AccessControl interface for the administration of the tokens.
Using TransferControl interface:
The admin can set a monthly fraction of the spending limit which means that every user can only spend the specified fraction of their tokens every month.
admin can restrict some addresses and specify a different limitation which makes them able to spend their tokens independent of the prevailing limitations.
Using TransactionFee interface:
Admins can set a fraction or a constant amount for every BLB token transfer. so it is considered as the internal gas fee.
transaction fees are sent to a third address which can be set by the admin.
if the transaction fee receiver is zero address, then the fee tokens are burned.
External Functions API:
BLB token contract consists of two main parts:
the openzeppelin pre-built open-source contracts.
the custom-developed unique contracts of BLB token.
we explain custom-developed functions here in detail. and link others to the openzeppelin docs.
/** * Creates amount tokens and assigns them to account, increasing the total supply. * * Emits a transfer event from set to the zero address. * * Requirements: * * account cannot be the zero address. * only role MINTER_ROLE can call this function. */functionmint(address to,uint256 amount)
function
/** * Mint amount of token to every member in accounts. * * Emits some transfer events with from set to the zero address to every account. * * Requirements: * * accounts cannot be the zero address. * only role MINTER_ROLE can call this function. */functionmintBatch(address[] accounts,uint256 amount)
abstract contract (TransactionFee)
deduct the transaction fee of every token transfer and send it to a third address.
functions and events API:
/** * @return feeAmount numerator of transaction fee which denominator is 1,000,000. * @return feeFraction independent transaction fee for every token transfer. * @return feeReceiver address of the fee receiver. */functionfeeDetails()
external function
/** * @return fee transaction fee corresponding to the transferring amount. * @notice if there is a fee amount, the transaction fee is not proportional to the * transferring amount. */functiontransactionFee(uint256 transferingAmount)
external function
/** * @notice set amount or fraction and receiver of BLB transaction fees. * * @notice if transaction receiver is zero address, the transaction fee will be burned. * * @notice requirement: * - Only role FEE_SETTER can call this function. * - one of the feeAmount or feeFraction must be zero. * - fee fraction can be a maximum of 50,000 which equals 5% of the transactions * * @dev emits a SetTransactionFee event */functionsetTransactionFee(uint256_feeAmount,uint256_feeFraction,address_feeReceiver)
event
/** * @dev emits when the admin sets a new transaction fee plan. */eventSetTransactionFee(uint256 _feeAmount, uint256 _feeFraction, address _feeReceiver)
abstract contract (TransferControl)
control BLB transfers.
users may have access to transfer their whole BLB balance or only a certain fraction every month(it depends on the monthly limit).
some specific addresses may have restricted access to transfer.
contract admin can restrict every desired address and also determine a spending limit for all users.
if an address is restricted then the public monthly limit is diactivated for it.
functions and events API:
external function
/** * @notice set spend limit for monthly transfers. * @notice there is no transfer limit if the fraction is 10**6. * * @param fraction the numerator of transfer limit rate which denominator * is 10**6. * * @notice require: * - only role TRANSFER_LIMIT_SETTER can call this function. * - maximum fraction can be 10**6 (equal to 100%). * * @notice emits a SetMonthlyTransferFraction event. */functionsetMonthlyTransferLimit(uint256 fraction)
external function
/** * @notice restrict an address * @notice the address `addr` will be only able to spend as much as `amount`. * * @param addr the restricted address. * @param amount restricted spendable amount. * * @notice require: * - only the RESTRICTOR_ROLE address can call this function. * * @notice emits a Restrict event. */functionrestrict(address addr,uint256 amount)
external function
/** * @notice district an address * @notice the address `addr` will be free to spend their BLB like regular * addresses. * * @param addr the address that is going to be districted. * * @notice require: * - only RESTRICTOR_ROLE address can call this function. * * @notice emits a District event. */functiondistrict(address addr)
/** * @return fraction the numerator of monthly transfer limit rate which denominator * is 10**6. */functionmonthlyLimit()
external function
/** * @return boolean true if the address is restricted. * * @param addr the address that is going to be checked. */functionisRestricted(address addr)
external function
/** * @return amount that the address can spend. * * @dev if the address is restricted, the amount equals the remaining spendable amount for the * address. else if there is a spending limit active for the contract, the amount equals the * address's remaining monthly spendable amount. else the amount equals the balance of the address. * * @param addr the address that is being checked. */functioncanSpend(address addr)
event
/** * @dev emits when the admin sets a new value as the monthlyLimit. */eventSetMonthlyTransferLimit(uint256 fraction)
event
/** * @dev emits when the admin restricts an address. */eventRestrict(address addr, uint256 amount);
event
/** * @dev emits when the admin districts an address. */eventDistrict(address addr);