here's the initial offering contract that sells BLB.
Features
the token fee can be paid in BNB and BUSD(USDT).
the main price is in USD but it can be calculated to the corresponding BNB in every buy transaction via the chainlink price feed aggregator.
there two sale plan; public sale price for small amounts and private sale price for large amounts of blb.
the contract is controlled by an owner using openzeppelin ownable standard interface.
External Functions API:
Ownable:
to see the pre-built APIs, visit openzeppelin Ownable functions API
main:
external function
/** * @return BLB address of the token contract. */functionBLB()
external function
/** * @return BUSD address of the token contract. */functionBLB()
external function
/** * @return price of the token in USD. * @notice the private and public price are calculated automatically. * @notice multiplied by 10^18. */functionpriceInUSD()
external function
/** * @return price of the token in BNB corresponding to the USD price. * @notice the private and public price are calculated automatically. * @notice multiplied by 10^18. */functionpriceInBNB()
external function
/** * @dev buy BLB Token paying in BNB. * * @notice multiplied by 10^18. * @notice maximum tolerance 2%. * * @notice requirement: * - there must be sufficient BLB tokens in ICO. * - required amount must be paid in BNB. * * @notice emits a BuyInBNB event */functionbuyInBNB(uint256 amount)
external function
/** * @dev buy BLB Token paying in BUSD(pegUSDT). * * @notice multiplied by 10^18. * * @notice requirement: * - there must be sufficient BLB tokens in ICO. * - Buyer must approve the ICO to spend the required BUSD. * * @notice emits a BuyInBUSD event */functionbuyInBUSD(uint256 amount)
event
/** * @dev emits when a user buys BLB, paying in BNB. */eventBuyInBNB(uint256indexed amountBLB, uint256indexed amountBNB);
event
/** * @dev emits when a user buys BLB, paying in BUSD. */eventBuyInBUSD(uint256indexed amountBLB, uint256indexed amountBUSD);
administration:
external function
/** * @return amount of the token in which the price decreases from retail to bulk. * * @notice multiplied by 10^18. */functionretailLimit()
external function
/** * @return price of the token in USD in bulk purchase. * * @notice multiplied by 10^18. */functionprivatePriceInUSD()
external function
/** * @return price of the token in USD in retail purchase. * * @notice multiplied by 10^18. */functionpublicPriceInUSD()
external function
/** * @dev set retail limit; * * @notice multiplied by 10^18. * * @notice requirement: * - only owner of the contract can call this function. * * @notice emits a SetPriceInUSD event */functionsetRetailLimit(uint256_retailLimit)
external function
/** * @dev set ticket price in USD for public sale and private sale; * * @notice multiplied by 10^18. * * @notice requirement: * - only owner of the contract can call this function. * * @notice emits a SetPriceInUSD event */functionsetPriceInUSD(uint256_publicPrice,uint256_privatePrice)
external function
/** * @dev withdraw ERC20 tokens from the contract. * * @notice requirement: * - only owner of the contract can call this function. * * @notice emits a Withdraw event */functionwithdrawERC20(address tokenAddr,uint256 amount)
external function
/** * @dev withdraw BNB from the contract. * * @notice requirement: * - only owner of the contract can call this function. * * @notice emits a Withdraw event(address zero as the BNB token) */functionwithdraw(uint256 amount)
event
/** * @dev emits when the owner sets a new retail limit. */eventSetRetailLimit(uint256indexed _retailLimit);
event
/** * @dev emits when the owner sets new prices for private and public blb sale (in USD). */eventSetPriceInUSD(uint256indexed publicPrice, uint256indexed privatePrice);
event
/** * @dev emits when the owner withdraws any amount of BNB or ERC20 token. * * @notice if the withdrawing token is BNB, tokenAddr equals address zero. */eventWithdraw(addressindexed tokenAddr, uint256indexed amount);