[SOLVED] Need some clarification in "How to Create an NFT Marketplace" tutorial by Daniel

This is the tutorial i am referring to https://www.youtube.com/watch?v=EMOYpgl5S1w

The video is perfect, but there is something which is unclear.

In the github cloudcode there is this line of code which is using a hash “0x77E…76EAf”

const nonceOperator = web3.eth.getTransactionCount(“0x77Ef4472cAc1AAca6B4bB82EA2bc41A6cf876EAf”)

As per the polygonscan this looks like a wallet address.

I did not understand the significance of this hash.
Is this like a intermediate wallet used for bidding?

1 Like

Hi John,

Thanks for the question.

You are right. This is the address of a wallet that I was using as Gateway. That should not be in the code, since you have to have your own gateway wallet for this project. I will update to have an empty string.

On what the code is doing in that specific line, It is merely getting the nonce (Correlative number of transactions from that specific wallet) in order to properly build the transaction data.


Best Regards


1 Like

Hi Daniel

Thanks for the easy explanation.
I am stuck at one more place while running this project.
I am trying to implement the same project on avalanche chain and I am seeing the below error saying “transaction underpriced”. This is happening when I am running place offering function.

I tried increasing gas price and then i started seeing the below error.

The gateway wallet which I am using for this transaction also has enough AVAX to run the transaction.

Thanks and Regards

from what value to what value you increased the gas price?

Initially it is 400000 and then i changed it to 25000000000, as it said in error that pool min cap fee is 25000000000. and then i changed it back to 8000000 as it said in error that current max gas is 8000000.
Now it is showing “exceeds block gas limit again” error.

Hi John,

Sorry for the late response. I don’t hang out here very often.
Let me clarify something a bit.

Gas price and quantity of gas are two different things.

  • Say you want to put a galon of gas in your car.
    – A Galon will be a galon today, tomorrow, the day after tomorrow.
    – The price of the gas, that one might change according to supply and demand.

  • In the EVM (Ethereum virtual machine) is the same.
    – The amount of gas your function consumes will be always the same.
    – The amount you are willing to pay per gas (galon of gas) varies.
    In the code below:
    gas:400000 //(this is the quantity of gas)
    gasPrice:web3.utils.toWei(“1”, “gwei”) //(this is the price of the gas)

The quantity of gas should not change, since the amount of work the EVM is doing is the same. So this you can leave the same.

The price, is the one that you need to change, the price of 1 gwei was OK when I made this project and for the network I demoed, which was not avalanche. This is the one that you need to adjust.

As you might have suspected by now, you were trying to put more gas in the car, when the guy in the gas station was telling you, hey buddy, you have not even enough to buy one galon here.

For troubleshooting.

1 - Try by merely commenting the gas and the gas price lines. (I don’t recall very well how the web3 instance in the cloud code works with this so I hardcoded them), it might be possible that the web3 environment in the cloudcode or in the js file will calculate this values for you in the current network.

  1. If the above doesn’t work try to just increase the price check in https://testnet.snowtrace.io/ the price of gas in Fuji network for the latest transaction.

At the moment of writing this comment is around 104 nAVAX (Gwei) quite more expensive than the 1 gwei that is hardcoded in the function.

By the way, not sure if you have done it but you need to change the chain on which the web3 instance is created. It was matic, you have to change it to fuiji. (I’m assuming you are in the testnet, if not you should, until you get everything tested).

On the error you are seeing, that is related to the limitation of amount of gas in each block. This limits the number of transactions making blocks more lean and easy to manage helping network decentralization. For hardcoded value of gas, return to the first one that was hardcoded.

Best Regards



Hi Daniel, Thanks for the reply.
I successfully cloned the NFT marketplace to Avalanche chain based on the tutorial.

I do have one more doubt.
Apparently when a NFT is sold on the marketplace with closeOffering(), the NFT is successfully sold to the buyer, but the price amount is not received to the sellers account. instead it is transferred to the marketplace contract.

For example: If “A” is Seller, “B” is Buyer and “C” is contract.
When “B” brought the NFT which “A” is selling for 1AVAX, the ownership of the NFT is given to “B” but the 1AVAX is transferred to “C” and held at “C”.

Is it possible to transfer back the 1AVAX from “C” to “A”.

Hi John.

The current design of the contract is to accumulate the proceeds of sales in the balance of the seller in the marketplace. This can be withdrawn by sellers at any time. The front-end has not implemented that function but this implementation is quite straight-forward.
Remember the following facts:

  • When someone buys your NFT you most likely will not be online to sign transfer the NFT to them. Even if both parties are online how to decide what will be done first. I send you my money or you send me your NFT.
  • You need to be able to grant an allowance to a third party to transfer the NFT on your behalf, but you also want to make sure that this third party only executes that allowance when a buyer pays the money you require to sell the NFT.
  • As well you want to make sure that you can withdraw the funds from the third party at any time.
  • Solving the issues above is the reason the market place exist in the first place.

You could in theory change the design in order the withdrawal function or some equivalent is executed by the buyer but it requires a bit of work to make such design secure. Besides that will be inefficient in several accounts. You will make buyers spend more gas, making their overall transaction cost higher. This gas costs are in all fairness cost that the seller should bear and the most efficient way for the seller is to withdraw when he wants maybe after several sales (transferring any amount of ETH costs the same amount of gas).


Hy there,
based on the video, you’ve created the sell and buy function and tested it successfully using your Test Mage collection. I’ve successfully code based on the video but the mage collection is empty. How to get the test mage NFT’s for testing the functions, or there is another way to test the function?

complete newbie.

For this you will need a NFT smart contract address, which has some minted NFTs.

In the video daniel used his own smart contract address which has test mage NFTs.

I’m a noob. How can i run this project? Cause nothing happens when i hit F5 on VSCODE, just a blank screen. Also i’m getting an error:

Source “OpenZeppelin/[email protected]/contracts/token/ERC721/ERC721.sol” not found: File import callback not supported

1 Like

Thank you for your reply.
How can I get my own smart contract address? how to mint my own NFTs to the address?
Is there any tutorial related to my question?

Thank you so much really appreciate it bro.

If you are looking for readymade contract which can be deployed on remix or to mint nft. Then use the below tutorial.

And if you are looking to understand how to actually write a nft contract and deploy then the below tutorial covers all the required basics. AND its a 2hr long video. Its totally worth it.

If u are a very beginner to NFTs and smart contracts then I recommend the ultimate nft tutorial.


Hi Evandro.

Welcome to the community.

To run this project you need to run a local http server. You can do that with Python 3 very easily. Python3 -m http.server in the terminal. You have to be positioned in the directory where the index html is.

This project is a bit complex if you are a complete newbie, specially because we aimed for a short walkthrough video for this tutorial. This could make it a bit difficult to follow if you don’t have background.

For running this project you need:

  • A moralis server.
  • NFTs that you control in the testnet that you are targeting. If you don’t have, then you will need to mint some (there is another tutorial on this mentioned in other post by @johnversus). Preferably if those NFTs are in an ERC-721 contract.
  • Deploy the Market Place smart contract. This you have to do using your favorite framework. The imports were largely vary according to the previous choice. So basically the way in which you write the import and how to get the dependencies is up to that decision.
  • You an account with private keys to manage the transactions of the market place. This account prevate key you put in the cloud code. For this tutorial we do it that way for simplicity but you’ll never do that in production you will have an external service that holds the key and that can return only very specific transactions after being requested with proper authentication.

Hope this helps.

Best regards


Im now working in a startup company here in my country, we are now working on to develop a NFT Marketplace and will use Moralis Paid Service. Looking forward for more guide and tutorials from you guys.

1 Like

have issue with yarn start trying your to build nft market i install the Yarn pk but its got a lot of issues. then i get this error . i cant seem to start app with Yarn Start ? anyone know how i can fix this please https://gyazo.com/cc499ca344ef616a236a6e6c5773cdb4 thank you

i have a noob question in relation to the tutorial:
there’s an “operator address” in the marketplace contract. what is the operator supposed to be? where do i get this address?

The operator’s address will be the contract owner’s wallet address / the one who deployed the contract.

You can change the operator with changeOperator function.

1 Like

Thanks for such an nice tutorial having a great information.
I also know US based company providing white label NFT marketplace development.