Giter Site home page Giter Site logo

nftmarketplacediamondstandard's Introduction

ERC721 Marketplace Contract

This is a Solidity smart contract for an ERC721 marketplace. It allows users to create and execute orders for ERC721 tokens, facilitating the exchange of these tokens for a specified price.

Table of Contents

Prerequisites

  • This contract is developed using Solidity version 0.8.19.
  • It relies on various libraries and structs, including ERC721Facet, SignUtils, and LibDiamond.

Contract Overview

The ERC721 marketplace contract enables users to create and execute orders for ERC721 tokens. Users can create an order specifying the token to be sold, the price, a deadline, and a cryptographic signature. Once created, the order can be executed by another user who pays the specified price, and the ERC721 token is transferred to the buyer, while the payment goes to the seller.

Error Handling

The contract includes several custom error types to handle different scenarios:

  • NotOwner: Thrown when the order creator does not own the specified ERC721 token.
  • DeadlinePassed: Thrown when the deadline for executing an order has passed.
  • InvalidPrice: Thrown when the specified price in the order is less than 0.01 ether.
  • InvalidSignature: Thrown when the order's cryptographic signature is invalid.
  • OrderExpired: Thrown when an order has passed its deadline and cannot be executed.
  • IncorrectPrice: Thrown when the value sent with an execution request does not match the order price.
  • NotApproved: Thrown when the contract is not approved to operate on the seller's ERC721 token.
  • InactiveOrder: Thrown when trying to execute an order that is not active.

Functions

createOrder

function createOrder(Order calldata order) external returns (uint256 orderId)

Creates a new order for an ERC721 token.

  • order: An order struct specifying the seller, ERC721 token address, token ID, price, deadline, signature, and whether the order is active.
  • Returns the unique order ID.

executeOrder

function executeOrder(uint256 orderId) external payable

Executes an existing order by transferring the specified amount of Ether and the corresponding ERC721 token to the buyer.

  • orderId: The unique ID of the order to be executed.
  • Requires the specified price to be sent with the execution request.

Please ensure that you have the required libraries and structs referenced correctly to use this contract. Additionally, make sure to handle the error scenarios described in the contract for a secure and reliable marketplace operation.

nftmarketplacediamondstandard's People

Contributors

mujibat avatar

Stargazers

Uttam Singh avatar Natachi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.