Decrease the number of gas fees

Hello everyone!

I am new to the whole smart contract and blockchain space, but I am developing a pet project on my free time, which is more like an NFT marketplace.

I have been using Solidity for the smart contracts and Moralis (a library) with Javascript.

I would like the seller of an NFT to not pay for any fees when they post their arts (just like Mintable). I just would like the buyer to pay for the price of the art + price of gas.

The first way I thought about implementing this is basically to only mint an NFT when a buyer wants to buy it (before that the NFT would just be sitting on a database and not on Ethereum’s blockchain). However, when the buyer buys this piece of art, I am being charged four gas fees:

  1. For the minting of the item
  2. To ensure the marketplace is approved
  3. Add item to the marketplace
  4. Buy item from the marketplace.

I currently have two contracts: one for the token and one for the marketplace.

Can anyone help me out with this? Or have any pointers and tips for how I can implement it?

Thank you very much in advance :slight_smile:

Hi @mauriciocosta , welcome to Open Zeppelin forums!

I am uncertain what you are actually asking. What is your question in specific?

I am being charged four gas fees:

For the minting of the item
To ensure the marketplace is approved
Add item to the marketplace
Buy item from the marketplace.

Allow the adding item and approving item to the marketplace to be free. The approval and creation would be handled on your server side.

Only mint when buying the item, and mint it directly to the buyer’s wallet.

1 transaction.

Check out Open Sea. They do something like that. https://docs.opensea.io/

1 Like

Thank you Tsushima! I'm very glad to be here.

Only mint when buying the item, and mint it directly to the buyer’s wallet.

That's what I thought too and that is my main goal to get to just 1 gas fee :slight_smile: . Minting the item is 1 gas fee. However, I also have to approve the market (1 gas fee) and transfer the funds from the buyer to the seller, and that is another gas fee (So: 3 gas fees).

How would you transfer funds (1 more gas fee) and approve the market (1 more gas fee) for such operation without gas fees? Because there should be interactions with the contract... Let me know what you think.

In summary: 1 gas fee for minting, 1 gas fee to approve the market, and 1 gas fee for transferring funds.

Have a nice day! I hope to hear back from you soon :slight_smile:

Mauricio.

This can all be done in one transaction step.

Yes it would be more calls, but it would be bundled in one gas fee paid for by the buyer.

In your “buy” function, it should handle approving (although I’m a little confused on this, approving the market shouldn’t be on chain, it should be on your front end), transferring funds, and then minting.

If you want your approvals to be done on chain, and validate the NFT to be shown on your market, that seems like an unnecessary on chain step. But if it is really required, then I think it can only reduce down to 2, because you will need to approve before buying.

1 Like

Thanks. You clarified some ideas to me. I will research more a bit.

1 Like