An NFT is a token that represents some digital asset. It can be used to represent in-game items, cryptocurrency, art, and even real estate. You can think of it as a representation of any digital asset you own on the blockchain.
NFTs are ERC-721 tokens. This means that they have been issued via an Ethereum smart contract and are stored within this contract for you to manage. This makes them unique, non-fungible tokens which allows them to be traded on the Ethereum blockchain with ease!
NFT extension
To import the extension, we do this:
“`javascript
import * as NFT from ‘./nft.js’
“`
The extension object is created in index.js and looks like this:
“`javascript
const Extension = {
/*** Method of the smart contract ***/
“`javascript
const methods = [NFT_CONTRACT_METHODS];
ERC721 Methods
The onERC721Received function is used to send a message to a smart contract that an event has occurred. This is useful for when you want to notify your smart contract about things like the purchase, transfer, or sale of ownership of an NFT.
This function can be overridden by inheriting from ERC721Metadata and overriding the `onERC721Received` method. For example:
“`javascript“`
““javascript“`
““javascript“`
ERC721Received function
The onERC721Received function is called when a new token is received. The function can be used to verify that the sender has the right to transfer the tokens they are sending, or perform any other checks needed to ensure that it’s safe to proceed with the transaction.
The onERC721Transferred function is called when an existing token is transferred between two accounts. It also takes care of updating balances in each account and transferring ETH if necessary, so you don’t have to worry about doing those things manually.
The onERC721Approved function is called when an account approves another account’s request for some amount of NFTs owned by them (e.g., a user approves another user’s request for 2 Pogs). It also updates balances in each account accordingly and transfers ETH if necessary, so again there isn’t much for you code-wise here other than deciding which users should have access and how many tokens are available per user/group at any given time during development mode versus production environment where the real money will be involved!
The onERC721Revoked function works similarly as above but allows revoking someone else’s approval instead rather than requesting yours…and vice versa!
Lastly, there is an option provided by the OpenZeppelin library we used which allows us to create burn events using the burn() method before our contract deploys into production mode where the real money will be involved since this method only works during development mode which makes sense because who wants paying fees just trying out something simple like burning tokens?
Implementing a Marketplace for NFTs
Most of the work to create an NFT marketplace is done by the ERC721 standard. To help you understand how it works, let’s break down all of the major parts:
- The NFT Contract (ERC721): This is the smart contract that holds your virtual assets. It keeps track of who owns what, and when their owners can be transferred or revoked.
- The NFT Extension (EIP-721): This extends the ERC20 token standard so that any contracts using it will also support non-fungible tokens! It makes life easier for developers like us because we don’t have to use new programming languages or learn how to implement our own way of handling these assets.
- Methods on an ERC20 Token Contract: These methods allow you access certain functionalities from within your application code—including transferring ownership between accounts, minting tokens based on certain conditions being met (like after receiving money), and checking if someone else has already claimed ownership over something before assigning them as yours too!
NFT smart contract
Finding NFT smart contract reliable service on the web can be a daunting experience, especially when it requires a full stack developer or maybe a team of developers on hand.
Reach out for further NFT smart contract discussions and projects directly to me.
0 Comments