MaxionNFTMarketplaceV2
is a smart contract developed on the Ethereum blockchain using Solidity. This contract facilitates the secure trading of ERC1155 NFTs in exchange for a specified ERC20 token.
- 🔐 Role-Based Access Control for administrative tasks, parameter updates, and trade handling.
- ⏸️ Pausable functionality to temporarily halt trading in emergency situations.
- 🔄 Supports safe ERC1155 transfers and ERC20 transfers using OpenZeppelin's libraries.
- 💸 Fees on trades, both fixed and percentage-based.
- 📦 Configurable fee beneficiaries.
Make sure you have hardhat
set up in your project.
To install necessary dependencies:
npm install @openzeppelin/contracts
The Trade Handler is a designated role within the contract, designed to oversee and execute trades between users. The inclusion of the TRADE_HANDLER_ROLE
ensures trading activities are handled securely and are exclusively conducted by entities possessing this role. In essence, the trade handler serves as a mediator between the buyer and seller to ensure the safe exchange of NFTs for the stated ERC20 token.
Functions the trade handler can access:
- trade(): Facilitates the trade between a buyer and seller. The handler ensures both parties meet the necessary criteria, calculates associated fees, and oversees the asset transfers.
Represented as FEE_DENOMINATOR
, this constant is integral for fee calculations. With a value of 10 ** 10
in this contract, its primary role is to support precise calculations without resorting to decimals. Since Ethereum smart contracts don't natively support floating-point arithmetic, the fee denominator is our solution to ensuring percentage-based fees are computed with utmost accuracy.
To demonstrate its use: to implement a 1% fee on a trade, you would assign feePercentage
the value of FEE_DENOMINATOR * 0.01
.
- FeeUpdated: Triggered when the percentage or fixed fee is updated.
- MinimumTradePriceUpdated: Emitted when the minimum trade price is adjusted.
- Sold: Logs trade details, including seller, buyer, and associated fees.
Detailing a few significant functions:
- setFees: Update the fee parameters.
- setMinimumTradePrice: Modify the minimum allowable trade price.
- pause: Temporarily halt all trading activities.
- unpause: Resume trading functionalities.
For a comprehensive list of functions and their descriptions, refer to the contract's code.
To compile the contract using hardhat:
npx hardhat compile
To run tests (assuming you have tests written):
npx hardhat test
Replace placeholders with actual values and use the following to deploy:
npx hardhat run --network bscTestnet scripts/deploy.ts
This contract uses the MIT license.
For any security concerns or issues, please reach out to [email protected].
For contributions, raise a PR or open an issue.