This repository houses the smart contract for Just NFTs written in Move.
This contract lets users mint NFTs, tranfer NFTs, and burn NFTs. It also has several utility functions that allow users to register a Token Store and opt-in to transfers.
just_nfts.move
- The main contract fileutils.move
- Utility functionsmint.move
- Minting Scipt to mint NFTs
Before calling any function make sure you call opt_into_transfer(account: &signer)
and register_token_store(account: &signer)
. This will make sure that you are able to mint and receive the NFTs. It will also make sure that you are able to receive transfers.
The mint(caller: &signer)
function can be called to mint and NFT to the caller's account.
It takes a reference to signer
as an argument.
This function will fail if the caller has not opted into the transfer and token store.
public entry fun mint(
caller: &signer
) acquires CollectionData
The transfer(owner: &signer, recipient: address, token_id: u128)
function can be called to transfer an NFT to the recipient.
It takes a reference to signer
, address
, and u128
as arguments.
This function will fail if the receiver has not opted into the transfer and token store or if the caller is not the owner of the set token. The function would also fail if the token does not exist or the token id is out of range.
public entry fun transfer(
owner: &signer,
recipient: address,
token_id: u128
) acquires CollectionData
The burn(caller: &signer, token_id: u128)
function can be called to burn an NFT.
It takes a reference to signer
and u128
as arguments.
This function will fail if the caller is not the owner of the set token. The function would also fail if the token does not exist or the token id is out of range.
public entry fun burn(
owner: &signer,
token_id: u128
) acquires CollectionData
The opt_into_transfer(account: &signer)
function can be called to opt into transfers. This allows the account to receive NFTs.
It takes a reference to signer
as an argument.
public entry fun opt_into_transfer(
account: &signer
)
The register_token_store(account: &signer)
function can be called to register a token store. This allows the account to store NFTs.
It takes a reference to signer
as an argument.
public entry fun register_token_store(
account: &signer
)
⚠️ You need the Aptos CLI to build the project.
To build the project run the following command:
aptos move compile --named-addresses nft_api=default --included-artifacts all
We include all aritifacts so that we get access to the ABI after compiling the contract.
⚠️ You need the Aptos CLI to test the project.
To test the project run the following command:
aptos move test --named-addresses nft_api=default
⚠️ You need the Aptos CLI to deploy the project.
To deploy the project run the following command:
aptos move publish --named-addresses nft_api=default
The contract would be published to the nft_api
address.