This repository contains a smart contract package for creating and auctioning Non-Fungible Tokens (NFTs) on the Sui blockchain. The package includes modules for NFT creation, auction management, and comprehensive testing.
This smart contract package allows users to:
- Create and mint NFTs
- Transfer NFT ownership
- Create auctions for NFTs
- Place bids on auctions
- End auctions and transfer NFTs to winners
- Automatically return NFTs to sellers if no bids are placed
The contract is written in the Move language for the Sui blockchain, ensuring secure and efficient operations.
The project consists of three main modules:
nft.move
: Handles NFT creation, minting, and transfers.auction.move
: Manages the auction process, including creation, bidding, and completion.auction_tests.move
: Contains comprehensive tests for both the NFT and auction functionalities.
Before you begin, ensure you have the following installed:
- Clone the repository:
git clone https://github.com/PGOpenda/nft_auction.git
cd nft-auction-sui
- Build the project:
sui move build
To create an NFT, use the mint
function in the nft
module:
nft::mint(name, description, image_url)
One can also transfer the NFT to another if they wished with transfer_nft
function in the same module:
nft::transfer_nft(nft,recipient)
To start an auction for an NFT, use the create_auction
function in the auction module. The duration is in milliseconds:
auction::create_auction(nft, min_bid, duration, clock)
To place a bid on an auction, use the place_bid
function in the auction module:
auction::place_bid(auction, clock, amount, ctx)
To end an auction, use the end_auction
function in the auction module:
auction::end_auction(auction, clock, ctx)
The winner can claim their NFT using the claim_nft function in the auction module:
auction::claim_nft(auction, ctx)
To deploy the package to the Sui network, we use the following commands in a command line interface:
- Build the package:
sui move build
- Deploy the package:
sui client publish --gas-budget 10000000
- Note the package ID from the output. You'll need this to interact with the deployed contract.
- You can also use Suiscan which provides an interface to interact with the package once deployed.
Run the tests using the following commands in your commad line interface:
sui move test
This will execute all tests in the nft_auction_tests
module, ensuring the correct functionality of both the NFT and auction features.
Contributions are welcome! Please feel free to submit a Pull Request.🙂 👍