# Write Contract

## Link to the Smart Contract:&#x20;

{% embed url="<https://bscscan.com/address/0x0a57483c0dead6f48a6a9253e3a3874787cf0dda#writeContract>" %}

**acceptBid**

This method gives the auction operator the ability to manually approve bids that deviate from the floor price, enhancing the auction's flexibility and responsiveness to market dynamics. It provides an additional layer of control over the auction process.

<table data-header-hidden><thead><tr><th width="212.33333333333331"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>_auctionId (uint256)</td><td>The unique identifier of the auction for which the bid is to be accepted.</td><td><ul><li>must be a number</li><li>ID must exist</li><li>must be the auction operator</li></ul></td></tr><tr><td>_bidder (address)</td><td>The address of the wallet from which the bid is being accepted.</td><td><ul><li>must be the bidder of the auction</li><li>must be an address</li></ul></td></tr></tbody></table>

**Transaction example**

{% embed url="<https://testnet.bscscan.com/tx/0xac2cae568aca1324661b866ec598d6db9c380c0a3b2fe10e49baa951016dc449>" %}
When Accepting a bid
{% endembed %}

<figure><img src="https://t26441698.p.clickup-attachments.com/t26441698/d2cde69b-0160-4097-b6a3-57972896c5c6/image.png" alt=""><figcaption></figcaption></figure>

**closeAuction**

This method serves a dual purpose, allowing the closure of an auction before its start (accessible only to the auction operator) and the collection of tokens and funds from the contract after its completion, catering to both bidders and the operator.

<table data-header-hidden><thead><tr><th width="213.33333333333331"></th><th width="265"></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>_auctionId (uint256)</td><td>The unique identifier of the auction for which we want close/collect tokens and funds.</td><td><ul><li>must be a number</li><li>ID must exist</li><li>must be the auction operator</li></ul></td></tr><tr><td>_data (bytes)</td><td>Additional data, if needed.</td><td><ul><li>By default, it is set to 0x00</li></ul></td></tr></tbody></table>

**Transaction Example**

{% embed url="<https://testnet.bscscan.com/tx/0xd9309b0e83df04eb3484b52dafdc78faab74903a1b4257a17726bd915bb309d7>" %}
The operator Finalizes the auction, 4 of 5 tokens were sold
{% endembed %}

<figure><img src="https://t26441698.p.clickup-attachments.com/t26441698/9925c2c0-97e1-44ba-90d9-b7fad0c03f91/image.png" alt=""><figcaption></figcaption></figure>

**a. Visible 2 transactions, the first is the treasury address but the second is the Operator address**

**b. Token Transfered FROM:** Address from where the money was sent

**c. Token Transferred To:** Address where the money is sent

**d. Token Transferred For:** The amount of money that was sent

**e. Token Transferred:** the currency

**f. Token Transfered FROM:** Address from where the token was sent

**g. Token Transferred To:** Address where the Token is sent

**h. Token Transferred:** ERC-1155 standard of the token

**i. Token Transferred:** Amount of tokens

**j. Token Transferred:** Token ID \[number of the token ID]

**k. Token Transferred:** Token Contract Address

**Transaction Example**

{% embed url="<https://testnet.bscscan.com/tx/0x33f5d2ef112419b6fc40d211177a9c2cbc8d19daf4f96c2096b557e76a8cd66d>" %}
One of the Winners Finalizes the Auction
{% endembed %}

<figure><img src="https://t26441698.p.clickup-attachments.com/t26441698/cbdc45a7-c9a0-4d63-9ed3-45a5683c1cf4/image.png" alt=""><figcaption></figcaption></figure>

**a.Visible 3 transactions, there are 3 levels of Referrals**

**b. Token Transfered FROM:** Address from where the money was sent

**c. Token Transferred To:** Address where the money is sent

**d. Token Transferred For:** The amount of money that was sent

**e. Token Transferred:** the currency

**f. Token Transfered FROM:** Address from where the token was sent

**g. Token Transferred To:** Address where the Token is sent

**h. Token Transferred:** ERC-1155 standard of the token

**i. Token Transferred:** Amount of tokens

**j. Token Transferred:** Token ID \[number of the token ID]

**k. Token Transferred:** Token Contract Address

**Transaction Example**

{% embed url="<https://testnet.bscscan.com/tx/0x33f5d2ef112419b6fc40d211177a9c2cbc8d19daf4f96c2096b557e76a8cd66d>" %}
The bidder who did not win the auction and after the delay claimed the money back from the Contract
{% endembed %}

<figure><img src="https://t26441698.p.clickup-attachments.com/t26441698/aa3168a9-440d-4d0e-b4e7-a188ab483cb8/image.png" alt=""><figcaption></figcaption></figure>

**a. Token Transfered FROM:** Address from where the money was sent

**b. Token Transferred To:** Address where the money is sent

**c. Token Transferred For:** The amount of money that was sent

**d. Token Transferred:** the currency

**createAuction**

This method is responsible for creating a bidding auction. To use this functionality, you must possess the tokens you want to sell or have created. The auction is characterized by setting a minimum price (floor price) that you wish to receive for the specific token. If no one attempts to bid higher than the floor price, the operator will have the option to consider an offer that falls below the floor price and decide whether to accept it for token sale or ignore it and retrieve the token back.

<table data-header-hidden><thead><tr><th width="210.33333333333331"></th><th width="282"></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>_tokenId (uint256)</td><td>The unique identifier of the token to be auctioned</td><td><ul><li>tokenID must be greater than 0</li><li>the INS creator must be an owner of the token</li></ul></td></tr><tr><td>_tokenContractAddress (address)</td><td>The address of the token contract where the token is located and will be listed for sale.</td><td><ul><li>must be a Token Contract Address</li></ul></td></tr><tr><td>_tokenQuantity (uint256)</td><td>The Number of tokens to be sent to the Bidding Auction</td><td><ul><li>must be a number</li><li>must be a owner of the token</li></ul></td></tr><tr><td>_maxBidTokenQuantity (uint256)</td><td>It can be ignored, it is used to limit the bid for a single user</td><td><ul><li>cannot be grater than token Quantity</li><li>must be a number</li></ul></td></tr><tr><td>_startBlock (uint256)</td><td>The block number at which the auction is scheduled to start.</td><td><ul><li>must be a blockchain block</li><li>must be lower than endBlock</li></ul></td></tr><tr><td>_endBlock (uint256)</td><td>The block number at which the auction is scheduled to end.</td><td><ul><li>must be a blockchain block</li><li>must be higher than startBlock</li></ul></td></tr><tr><td>_tokenFloorPrice (uint256)</td><td>The floor price set for a single token, is expressed in the units of the specified token (e.g., 0.0001 BUSD is represented as 1e14 in our case).</td><td><ul><li>must be a positive number</li><li>possible min price 0.0001 BUSD</li></ul></td></tr><tr><td>_level1ReferralFee (uint256)</td><td>The amount of referral fee received by the person who refers the auction at level 1. It can be selected from 0 to 15% of the transaction amount. The sum of referral fees from all referrers cannot exceed 15%.</td><td><ul><li>can be set from 0 to 15% (1% = 100)</li><li>the max sum of the referral fee must be set to 15%</li></ul></td></tr><tr><td>_level2ReferralFee (uint256)</td><td>The amount of referral fee received by the person who refers the auction at level 2. Can be selected from 0 to 15% of the transaction amount. The sum of referral fees from all referrers cannot exceed 15%.</td><td><ul><li>can be set from 0 to 15% (1% = 100)</li><li>the max sum of the referral fee must be set to 15%</li></ul></td></tr><tr><td>_level3ReferralFee (uint256)</td><td>The amount of referral fee received by the person who refers the auction at level 3. Can be selected from 0 to 15% of the transaction amount. The sum of referral fees from all referrers cannot exceed 15%.</td><td><ul><li>can be set from 0 to 15% (1% = 100)</li><li>the max sum of the referral fee must be set to 15%</li></ul></td></tr><tr><td>_data (bytes)</td><td>Additional data, if needed.</td><td><ul><li>By default, it is set to 0x00</li></ul></td></tr></tbody></table>

**Transaction Example**

{% embed url="<https://testnet.bscscan.com/tx/0x33f5d2ef112419b6fc40d211177a9c2cbc8d19daf4f96c2096b557e76a8cd66d>" %}
Creation of the Auction
{% endembed %}

<figure><img src="https://t26441698.p.clickup-attachments.com/t26441698/dee15c47-3dd6-4277-9530-926daa3c2553/image.png" alt=""><figcaption></figcaption></figure>

**a. Token Transfered FROM:** Address from where the token was sent

**b. Token Transferred To:** Address where the Token is sent

**c. Token Transferred:** ERC-1155 standard of the token

**d. Token Transferred:** Amount of tokens

**e. Token Transferred:** Token ID \[number of the token ID]

**f. Token Transferred:** Token Contract Address

**onERC1155BatchReceived**

The onERC1155BatchReceived is a standard function within the ERC-1155 interface in the Solidity environment, similar to onERC1155Received. However, it is used to handle the batch (multiple) receipt of tokens by a contract. When an address receives a batch of tokens (either NFTs or MFTs) on its contract, if that contract includes the onERC1155BatchReceived method, it is automatically invoked. This allows the contract to respond to the receipt of multiple tokens in a single transaction and execute appropriate actions.

<table data-header-hidden><thead><tr><th width="213.33333333333331"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>address (operator)</td><td>The address performing the token batch transfer operation.</td><td><ul><li>must be an address</li></ul></td></tr><tr><td>address (from)</td><td>The address from which the tokens were sent.</td><td><ul><li>must be an address</li></ul></td></tr><tr><td>uint256[] (tokenID)</td><td>An array of token identifiers.</td><td><ul><li>must be a number</li></ul></td></tr><tr><td>uint256[] (value)</td><td>An array of amounts of received tokens corresponding to the respective IDs.</td><td><ul><li>must be a number</li></ul></td></tr><tr><td>bytes</td><td>Additional data passed along with the transfer operation.</td><td><ul><li>By default, it is set to 0x00</li></ul></td></tr></tbody></table>

The onERC1155Received function returns a special four-byte code (bytes4), which serves as a confirmation that the contract successfully received the tokens. In summary, onERC1155BatchReceived allows a contract to react to the receipt of a batch of ERC-1155 tokens and execute specific actions in response to this batch event.

**onERC1155Recevied**

The onERC1155Received function is a standard function within the ERC-1155 interface in the Solidity environment, concerning non-fungible tokens (NFTs) or multi-fungible tokens (MFTs). This function is designed to handle the receipt of tokens by a contract. When an address receives tokens (either NFTs or MFTs) on its contract, if that contract includes the onERC1155Received function, it is automatically invoked. This allows the contract to respond to the receipt of new tokens and execute appropriate actions.

<table data-header-hidden><thead><tr><th width="208.33333333333331"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>address (operator)</td><td>The address performing the token transfer operation.</td><td><ul><li>must be an address</li></ul></td></tr><tr><td>address (from)</td><td>The address from which the tokens were sent.</td><td><ul><li>must be an address</li></ul></td></tr><tr><td>uint256 (tokenID)</td><td>The token identifier.</td><td><ul><li>must be a number</li></ul></td></tr><tr><td>uint256 (value)</td><td>The number of received tokens.</td><td><ul><li>must be number</li></ul></td></tr><tr><td>bytes</td><td>Additional data passed along with the transfer operation.</td><td><ul><li>By default, it is set to 0x00</li></ul></td></tr></tbody></table>

The onERC1155Received function returns a special four-byte code (bytes4), which serves as a confirmation that the contract successfully received the tokens. In summary, onERC1155Received enables a contract to react to the receipt of ERC-1155 tokens and trigger specific actions in response to this event.

**placeBid**

The placeBid method allows users to participate in an auction by placing a bid. Users can also use this method to increase their current bid amount or the quantity of tokens they are bidding.

<table data-header-hidden><thead><tr><th width="177.33333333333331"></th><th width="309"></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>_auctionId (uint256)</td><td>The unique identifier of the auction in which the user wants to place the bid.</td><td><ul><li>must be a number</li><li>must be a valid auction id</li></ul></td></tr><tr><td>_pricePerToken (uint256)</td><td>The price set for a single token, expressed in the units of the specified token (e.g., 0.0001 BUSD is represented as 1e14 in our case).</td><td><ul><li>must be a positive number</li><li>possible min price 0.0001 BUSD</li></ul></td></tr><tr><td>_tokenQuantity (uint256)</td><td>The number of tokens to be sent for the auction.</td><td><ul><li>cannot be 0</li><li>cannot be greater than owned tokens</li></ul></td></tr><tr><td>_referrer (address)</td><td>The address of the wallet from which we received the auction recommendation or the address of the person who registered us as an upline. If the user purchases the auction through a referral, the referrer will receive a commission from the transaction based on the agreed commission and referral level.</td><td><ul><li>must be a valid address</li></ul></td></tr></tbody></table>

**Transaction Example**

{% embed url="<https://testnet.bscscan.com/tx/0x33f5d2ef112419b6fc40d211177a9c2cbc8d19daf4f96c2096b557e76a8cd66d>" %}
Creation of the Auction
{% endembed %}

<figure><img src="https://t26441698.p.clickup-attachments.com/t26441698/64999439-79de-4b07-9636-e0785ebc357d/image.png" alt=""><figcaption></figcaption></figure>

**a. Token Transfered FROM:** Address from where the money was sent

**b. Token Transferred To:** Address where the money is sent

**c. Token Transferred For:** The amount of money that was sent

**d. Token Transferred:** the currency

**removeBid**

The removeBid method is responsible for removing a bid placed in an auction. This method allows users to withdraw their bids from an auction in which they are participating. This can be helpful if a user wants to cancel their participation or for mistake bids a higher price. After removing a bid, users can place a new bid if they wish.

| **Data**              | **Description**                                                    | **Restrictions**                                              |
| --------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------- |
| \_auctionId (uint256) | The ID of the auction from which the user wants to remove the bid. | <ul><li>must be a number</li><li>must be a valid ID</li></ul> |

**renounceOwnership**

* This method **allows the contract's owner** to renounce their ownership. This method is accessible only to the contract's owner.
* This function enables the current owner to renounce ownership of the contract. Once this method is called, the owner will lose their privileges to manage the contract, and any methods that require owner permissions will no longer be accessible.

**setAddresses**

The setAddresses method is exclusively accessible to the contract owner. It empowers the owner to establish new addresses for the BUSD (Binance USD), Treasury Referral, and Royalty contracts.

<table data-header-hidden><thead><tr><th width="184.33333333333331"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>_busdAddress (address)</td><td>The fresh address for the BUSD contract.</td><td><ul><li>Only for the Contract owner</li><li>must be an address</li></ul></td></tr><tr><td>_treasuryAddress (address)</td><td>The updated address for the Treasury contract.</td><td><ul><li>Only for the Contract owner</li><li>must be an address</li></ul></td></tr><tr><td>_referralAddress (address)</td><td>The revised address for the Referral contract.</td><td><ul><li>Only for the Contract owner</li><li>must be an address</li></ul></td></tr><tr><td>_royaltyAddress (address)</td><td>The modified address for the Royalty contract.</td><td><ul><li>Only for the Contract owner</li><li>must be an address</li></ul></td></tr></tbody></table>

**setFinalizationBlockDelay**

The setFinalizationBlockDelay method is exclusively accessible to the contract owner. It empowers the owner to define the time window within which the auction operator can accept bids.

<table data-header-hidden><thead><tr><th width="228.33333333333331"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>_finalizationBlockDelay (uint256)</td><td>The quantity of blocks by which the finalization of auctions should be delayed.</td><td><ul><li>must be a number</li></ul></td></tr></tbody></table>

**setTreasuryFee**

This method is used to set the transaction fee in the contract. It is accessible only to the contract's owner.

<table data-header-hidden><thead><tr><th width="177.33333333333331"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>_fee (uint256)</td><td>The amount of the transaction fee to be set.</td><td><ul><li>Only for the Contract owner</li><li>Must be a positive number</li></ul></td></tr></tbody></table>

**transferOwnership**

The method is **available only to the current owner** **of the contract** and allows changing the ownership of the contract

<table data-header-hidden><thead><tr><th width="212.33333333333331"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Data</strong></td><td><strong>Description</strong></td><td><strong>Restrictions</strong></td></tr><tr><td>newOwner (address)</td><td>The address of the new contract owner.</td><td><ul><li>must be a wallet address</li></ul></td></tr></tbody></table>
