# Functions

### **allowance**

An address can give power to another address to spend its tokens. Users can adjust allowed tokens by increasing allowance and decreasing allowance commands. Allowance can be checked in the contracts read section.&#x20;



### **buy**

The main minting function for the tokens.

1. Asks amount in BNB for selling tokens.
2. Calculates token quantity by using rate and input amount.
3. Checks if the msg.value is equal to or lower than 10 BNB (total buy limit for each address). If not, rejects.
4. Checks calculated tokens + user token balance. If the sum is higher than the personal cap, it rejects.
5. Checks total sold tokens + requested amount. If the total is higher than hard cap tokens, it rejects.
6. If all conditions are true, it mints the tokens to msg.sender. By minting it updates msg.sender's balances for BNB Wei and BMNY token.



### **receive**

The minting function for the BNB is transferred to the contract directly.

1. Calculates token quantity by using rate and msg.value.
2. Checks if the msg.value is equal to or lower than 10 BNB (total buy limit for each address). If not, rejects.
3. Checks calculated tokens + user token balance. If the sum is higher than the personal cap, it rejects.
4. Checks total sold tokens + requested amount. If the total is higher than hard cap tokens, it rejects.
5. If all conditions are true, it mints the tokens to msg.sender. By minting it updates msg.sender's balances for BNB Wei and BMNY token.



### stove

The burning function.

1. It checks whether it is time to burn.The initial burn time is 13 months after the contract creation time.
2. Burns the tokens collected.
3. The new burning date is automatically set as one month after the stove is used.

### refundAndBurn

It allows users to refund their funds if the soft cap is not reached.

1. To prevent failure, msg.sender must enter the wallet address.
2. Checks quantity of total sold tokens of BMNY. If it is higher than the soft cap amount, it rejects.
3. It checks the soft cap deadline. If it is not passed, it rejects
4. Checks user balance and must see the purchased tokens. If the tokens are not in the wallet, it rejects.
5. If all conditions are passed, it refunds the BNB funds of the msg.sender and burns the BMNY tokens.



### finalizeSale

It gives the possibility to finish sales.

1. Checks if the msg.sender is the contract creator.
2. Checks if the sale period passed 12 months. If not, rejects.
3. If conditions are true, it mints the unsold tokens to the stove address.





### OTHER FUNCTIONS

Please check also other functions from the contract such as balanceOf,  getPrice, hardCapTokens, softCapTokens, softCapDeadline, sale\_finished, totalSoldTokens, totalSupply, claimedLocked.
