NFT-Marketplace-Part-1.md at main · LearnWeb3DAO

Содержание
  1. Name already in use
  2. aptos-nft-marketplace
  3. Here is 1 public repository matching this topic…
  4. Improve this page
  5. Add this topic to your repo
  6. NFT Marketplace
  7. Technology Stack & Tools
  8. Requirements For Initial Setup
  9. Setting Up
  10. 1. Clone/Download the Repository
  11. 2. Install Dependencies:
  12. 3. Boot up local development blockchain
  13. 4. Connect development blockchain accounts to Metamask
  14. 5. Migrate Smart Contracts
  15. 6. Run Tests
  16. 7. Launch Frontend
  17. License
  18. Open Source Nft Marketplace [Onprogress %10]
  19. ⭐ Support Us
  20. 💪 Motivation
  21. 🖥️ Screenshoots
  22. Home
  23. Explore
  24. Nft Detail
  25. Augmented Reality Support
  26. 🎉 Roadmap
  27. 🔮 Usage
  28. npm install (for first running)
  29. npm start
  30. 🗞️ Docs
  31. 🤝 Contribute
  32. Contributors ✨
  33. Here are 530 public repositories matching this topic…
  34. Improve this page
  35. Add this topic to your repo
  36. NFT Marketplace Built With Polygon, Solidity, IPFS & Next.js
  37. Objective
  38. Run this project
  39. How to setup locally?
  40. 1. Clone the project locally, change into the directory, and install the dependencies:
  41. 2. Start the local Hardhat node
  42. 3. With the network running, deploy the contracts to the local network in a separate terminal window
  43. 4. Start the app
  44. Configuration
  45. Deploy into Mumbai test network
  46. Deploying to Mainnet
  47. Ship a true NFT Marketplace on Celo — Part 1
  48. 🤩 Final Output
  49. Smart Contracts
  50. 👨‍🔬 Setting Up
  51. 🎨 Building an NFT Contract
  52. 💻 Writing the marketplace smart contract
  53. 🚢 Shipping It
  54. 🌟 Next Steps
  55. Improve this page
  56. Improve this page
  57. Add this topic to your repo
  58. Add this topic to your repo
  59. Files
  60. Overview
  61. To run the app

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

1


0

aptos-nft-marketplace

Here is
1 public repository
matching this topic…

A full stack demo NFT marketplace based on aptos devnet.

  • Updated
    Oct 12, 2022

Improve this page

Add a description, image, and links to the

topic page so that developers can more easily learn about it.


Curate this topic

Add this topic to your repo

To associate your repository with the

topic, visit your repo’s landing page and select «manage topics.»

NFT Marketplace

Technology Stack & Tools

  • Solidity (Writing Smart Contract)
  • Javascript (React & Testing)
  • Ethers (Blockchain Interaction)
  • Hardhat (Development Framework)
  • Ipfs (Metadata storage)
  • React routers (Navigational components)

Requirements For Initial Setup

Setting Up

1. Clone/Download the Repository

2. Install Dependencies:

$ cd nft_marketplace
$ npm install

3. Boot up local development blockchain

$ cd nft_marketplace
$ npx hardhat node

4. Connect development blockchain accounts to Metamask

  • Copy private key of the addresses and import to Metamask
  • Connect your metamask to hardhat blockchain, network 127.0.0.1:8545.
  • If you have not added hardhat to the list of networks on your metamask, open up a browser, click the fox icon, then click the top center dropdown button that lists all the available networks then click add networks. A form should pop up. For the «Network Name» field enter «Hardhat». For the «New RPC URL» field enter «http://127.0.0.1:8545«. For the chain ID enter «31337». Then click save.

5. Migrate Smart Contracts

npx hardhat run src/backend/scripts/deploy.js --network localhost

6. Run Tests

$ npx hardhat test

7. Launch Frontend

$ npm run start

License

Open Source Nft Marketplace [Onprogress %10]

All Contributors

Reactjs And Smart Contracts Open Source Basic Nft Marketplace App

⭐ Support Us

If you like our project, do not forget to give stars. So we can get more attention and get more support from the community. Don’t underestimate one star, one star you give will convince others to give the project another star.

💪 Motivation

I aim to create an open and safe nft marketplace for everyone. This will be a challenge for both me and the contributors. Together we will create an open source, reliable and beautiful nft marketplace example. The purpose of this project is not to operate an nft marketplace, but to create a template for nft marketplaces. Thus, many nft marketplaces can be easily created by forking and modifying this template. This will be beneficial for us to support the artists. We can only succeed in the world by coming from different areas and joining our forces.

🖥️ Screenshoots

Home

NFT-Marketplace-Part-1.md at main · LearnWeb3DAO

Explore

explore

Nft Detail

detail

Augmented Reality Support

ar
ar
NFT Marketplace Augmented Reality Support Video

🎉 Roadmap

  • Base Components (9/9) (Base components of the project )
  • Search Filters for Explore Page
  • Connect Wallet (ETH Wallets)(Supports Other Wallets 🚀)
  • NFT Detail Page
  • Smartcontract Backend (Truffle)
  • Community Page
  • Login
  • NFT Create Page
  • Users Pages
  • User Collections
  • Connect Wallet Popup
  • Supported Mobile Devices
  • AR supports for 3d NFTs

🔮 Usage

In the project directory, you can run:

npm install (for first running)

npm start

🗞️ Docs

🤝 Contribute

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Here are
530 public repositories
matching this topic…

  • Updated
    Jan 14, 2022
  • Updated
    Mar 18, 2022

NFT Marketplace 🚀

  • Updated
    May 5, 2022
  • Updated
    May 1, 2022

llenge)”1against-1” (winner keeps 2art pieces)

  • Updated
    Apr 23, 2022

metaverse-old
  • Updated
    Feb 5, 2022

integration of the Wat search engine to reservoir.marketplace

  • Updated
    Jul 20, 2022

Buy, sell and collect your NFT in an easy, fast and decentralized way

  • Updated
    Jun 7, 2022

Please be patient with me, Im soooooooooo

  • Updated
    Apr 24, 2022

WhiteListing Smart Contract Developed in Solidity and Go (for Interacting with smart contract)

  • Updated
    Apr 28, 2022

Contracts and scripts for NFT & NFT marketplace

  • Updated
    Oct 6, 2022
  • Updated
    Sep 4, 2022
  • Updated
    Sep 3, 2022

NFT’s image generator

  • Updated
    Nov 15, 2022

BuyCoin player send «PlayerSendCryptoAmount» coins to Game Owner address ,and get «PlayerGetGameGolds» game golds. CreateWallet Create new wallet ShowMyWallet Show Player Wallet info. Artists have historically been very limited in ways they can monetarily capitalize on their work. The places that have popped up which allow them to do so in the w

  • Updated
    Nov 4, 2022
  • Updated
    Nov 10, 2022
Про NFT:  Откройте для себя возможности чата для сбора данных NFT: пошаговое руководство и советы

Build NFT Drop Dapp with NEXT.JS !

  • Updated
    Nov 28, 2022

NFT marketplace on Aptos Devnet.

  • Updated
    Dec 6, 2022

NFT marketplace on Aptos Devnet.

  • Updated
    Nov 2, 2022
  • Updated
    Jan 1, 2022

<!— —>

Improve this page

Add a description, image, and links to the

topic page so that developers can more easily learn about it.


Curate this topic

Add this topic to your repo

To associate your repository with the

topic, visit your repo’s landing page and select «manage topics.»

NFT Marketplace Built With Polygon, Solidity, IPFS & Next.js

Header

NFT Marketplace Built With Polygon, Solidity, IPFS & Next.js

Objective

Create NFT Marketplace With Below Options.

  • Home
  • Sell Digital Asset
  • My Digital Assets
  • Creator Dashboard

Run this project

How to setup locally?

1. Clone the project locally, change into the directory, and install the dependencies:

git clone https://github.com/TravelXML/POLYGON-NFT-MARKETPLACE.git POLYGON-NFT-MARKETPLACE install using NPM or Yarnnpm install
yarn

2. Start the local Hardhat node

3. With the network running, deploy the contracts to the local network in a separate terminal window

npx hardhat run scripts/deploy.js --network localhost

4. Start the app

image

Click on Sell Digital Asset

image

Click on Home

image

Configuration

To deploy to Polygon test or main networks, update the configurations located in hardhat.config.js to use a private key and, optionally, deploy to a private RPC like Infura.

 : : : : : : : : : : 

If using Infura, update .infuraid with your Infura project ID.

Deploy into Mumbai test network

  • Network Name: Mumbai TestNet

  • Chain ID: 80001

  • Currency Symbol: Matic

image

Save this, then you should be able to switch to and use the new network!

To get these, you can visit the Matic Faucet, inputting the address of the wallets that you would like to request the tokens for.
Deploying to the Matic / Polygon network.
image

Now that you have some Matic tokens, you can deploy to the Polygon network!

image

To do so, be sure that the address associated with the private key you are deploying your contract with has received some Matic tokens in order to pay the gas fees for the transaction.

npx hardhat run scripts/deploy.js --network mumbai

Once the contracts have been deployed, you should be able to update the contract addresses in your project and test on the new network 🎉!

File Name: config.js

image

change to smart contract deployed address:

image

Change the JSON Provider in index.js file loadNFTs()

const provider = new ethers.providers.JsonRpcProvider()

image

Then good to up the server, Run below command

After Deploying to Mumbai Test Network, you scan your address and see what all transactions occurred.
image

Finally Here is the NFT Marketplace!

image

Deploying to Mainnet

To deploy to the main Matic / Polygon network, you can use the same steps we set up for the Mumbai test network.

The main difference is that you’ll need to use an endpoint for Matic as well as import the network into your MetaMask wallet as listed here.

An example update in your project to make this happen might look like this:

/* hardhat.config.js *//* adding Matic main network config to existing config */...
matic: : : 

Public RPCs like the one listed above may have traffic or rate-limits depending on usage. You can sign up for a dedicated free RPC URL using services like Infura, MaticVigil, QuickNode, Chainstack, or Ankr.

For example, using something like Infura:

Congratulations! You’ve deployed a NFT Marketplace to Polygon.

Happy Coding! 💓

Ship a true NFT Marketplace on Celo — Part 1

NFT-Marketplace-Part-1.md at main · LearnWeb3DAO

In this level, we will be building OUR OWN NFT marketplace, similar to OpenSea, completely from scratch on Celo!

We will use a bunch of developer tools to make this possible, and this is going to be an amazing level!

  • Hardhat
  • NextJS (React)
  • Celo
  • The Graph
  • Rainbowkit
  • Wagmi
  • Ethers.js
  • Metamask / Alfajores Wallet

We will divide this lesson into three parts — Smart contracts, Subgraph, and Frontend.

🤩 Final Output

This is what we will be building, by the end of this lesson series:

NFT-Marketplace-Part-1.md at main · LearnWeb3DAO
NFT-Marketplace-Part-1.md at main · LearnWeb3DAO


Smart Contracts

mkdir celo-nft-marketplace celo-nft-marketplace
git init
  1. createListing: Create a listing to put an NFT up for sale
  2. cancelListing: Cancel a listing you previously created
  3. updateListing Update a listing you previously created
  4. purchaseListing: Purchase a listing from someone else

This is a minimalistic version of what goes on in a decentralized NFT marketplace, but it fits well for our purpose.

👨‍🔬 Setting Up

Let’s set up a new Hardhat project to write our smart contracts.

  1. Open up a terminal, and create a folder for Hardhat within the directory you just created
 celo-nft-marketplace
mkdir hardhat hardhat
  1. To set up the project, execute these commands

npm init --yes
npm install --save-dev hardhat
  1. If you are on Windows, please do this extra step and install these libraries as well 🙂
npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers
  1. Finally, run the following command and go through the interactive prompt
  • Select Create a basic sample project
  • Press enter for the already specified Hardhat Project Root
  • Press enter for the question on if you want to add a .gitignore
  • Press enter for Do you want to install this sample project's dependencies with npm (@nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers)?

We now have our Hardhat project ready to go!

  1. Let’s also install OpenZeppelin contracts library while we’re here, as we will use IERC721.sol later
npm install @openzeppelin/contracts

🎨 Building an NFT Contract

Before we build our marketplace, we need to build a simple NFT contract so you actually have some NFTs on testnet you can test this out with. We will not go into too much detail for this, as by this point it should be fairly straightforward.

If you are not familiar with writing NFT contracts, check out the NFT Collection tutorial in the Sophomore track.

Open up the folder in your code editor, and create a new file under hardhat/contracts called CeloNFT.sol. We will use this file to write a simple NFT contract

<div dir="auto" data-snippet-clipboard-copy-content="// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract CeloNFT is ERC721 {
constructor() ERC721("CeloNFT", "cNFT") {
// mint 5 NFTs to yourself
for (uint i = 0; i

// SPDX-License-Identifier: MIT ; ; { () (, ) { // mint 5 NFTs to yourself ( i ; i ; i) { (., i); } } // Hardcoded token URI will return the same metadata // for each NFT () ( ) { ; }
}
Про NFT:  Добейтесь успеха в игре NFT с NFT Sharks: советы и подсказки

We will write the deployment script for this later, along with the one for CeloNFTMarketplace that is coming up.

💻 Writing the marketplace smart contract

Open up the folder in your code editor, and create a new file under hardhat/contracts called NFTMarketplace.sol. We will use this file to write all of our smart contract code!

We start off with the basic boilerplate.

// SPDX-License-Identifier: MIT ; ; {
}

Let’s try to think through how we should structure this code. Looking at the functions we want, everything is centered around the idea of Listings.

  • It might make sense to have a struct to represent all the data in a Listing.
  • NFTs from all various different collections can be traded on the marketplace. So a Listing must represent the NFT contract address, the token ID, the seller address, and the price at the very least.
  • To allow for easy access to Listing data, we can store it as a 2D Mapping of Contract Address -> (Token ID -> Listing Data)
  • The marketplace should have approval over transferring NFTs that were listed when a buyer purchases a listing
mapping(uint256 => Listing)) public listings;»>
 { price; seller;
}
( ( Listing)) listings;

Let’s write the createListing function now.

<div dir="auto" data-snippet-clipboard-copy-content="function createListing(
address nftAddress,
uint256 tokenId,
uint256 price
) external {
// Cannot create a listing to sell NFT for 0, "MRKT: Price must be > 0");

// If listing already existed, listing.price != 0
require(
listings[nftAddress][tokenId].price == 0,
"MRKT: Already listed"
);

// Check caller is owner of NFT, and has approved
// the marketplace contract to transfer on their behalf
IERC721 nftContract = IERC721(nftAddress);
require(nftContract.ownerOf(tokenId) == msg.sender, "MRKT: Not the owner");
require(
nftContract.isApprovedForAll(msg.sender, address(this)) ||
nftContract.getApproved(tokenId) == address(this),
"MRKT: No approval for NFT"
);

// Add the listing to our mapping
listings[nftAddress][tokenId] = Listing({
price: price,
seller: msg.sender
});
}»>

( , , ) { // Cannot create a listing to sell NFT for < 0 ETH (price , "MRKT: Price must be > 0"); // If listing already existed, listing.price != 0 ( listings[nftAddress][tokenId].price , "MRKT: Already listed" ); // Check caller is owner of NFT, and has approved // the marketplace contract to transfer on their behalf nftContract (nftAddress); (nftContract.(tokenId) ., "MRKT: Not the owner"); ( nftContract.(., ()) nftContract.(tokenId) (), "MRKT: No approval for NFT" ); // Add the listing to our mapping listings[nftAddress][tokenId] ({ price: price, seller: . });
}

There’s a couple of things we can still do here.

  1. Some of the require statements can be abstracted into modifiers, as they will be used across other functions. NFT owner checks and whether or not a listing is already created, specifically.
  2. We should emit an event when a listing is created. This will help our subgraph later to know that a new listing has been created, and will allow our frontend to render data accordingly.
0, "MRKT: Not listed");
_;
}

event ListingCreated(
address nftAddress,
uint256 tokenId,
uint256 price,
address seller
);»>

// Requires the msg.sender is the owner of the specified NFT( , ) { ( (nftAddress).(tokenId) ., "MRKT: Not the owner" );
}// Requires that the specified NFT is not already listed for sale( , ) { ( listings[nftAddress][tokenId].price , "MRKT: Already listed" );
}// Requires that the specified NFT is already listed for sale( , ) { (listings[nftAddress][tokenId].price , "MRKT: Not listed");
}
( , , ,
);

Now, we can update createListing to be

0, "MRKT: Price must be > 0");
IERC721 nftContract = IERC721(nftAddress);
require(
nftContract.isApprovedForAll(msg.sender, address(this)) ||
nftContract.getApproved(tokenId) == address(this),
"MRKT: No approval for NFT"
);
listings[nftAddress][tokenId] = Listing({
price: price,
seller: msg.sender
});

emit ListingCreated(nftAddress, tokenId, price, msg.sender);
}»>

( , , ) (nftAddress, tokenId) (nftAddress, tokenId) { (price , "MRKT: Price must be > 0"); nftContract (nftAddress); ( nftContract.(., ()) nftContract.(tokenId) (), "MRKT: No approval for NFT" ); listings[nftAddress][tokenId] ({ price: price, seller: . }); (nftAddress, tokenId, price, .); }

Great! Let’s do cancelListing now, which is quite straightforward. We will also add a new event for ListingCanceled and emit that as part of the function to assist with indexing later.

( , , );
( , ) (nftAddress, tokenId) (nftAddress, tokenId)
{ // Delete the Listing struct from the mapping // Freeing up storage saves gas! listings[nftAddress][tokenId]; // Emit the event (nftAddress, tokenId, .);
}

Amazing! Doing great so far!

updateListing is also equally straightforward, and we will create an event definition to go with it as well.

<div dir="auto" data-snippet-clipboard-copy-content="event ListingUpdated(
address nftAddress,
uint256 tokenId,
uint256 newPrice,
address seller
);

function updateListing(
address nftAddress,
uint256 tokenId,
uint256 newPrice
) external isListed(nftAddress, tokenId) isNFTOwner(nftAddress, tokenId) {
// Cannot update the price to be 0, "MRKT: Price must be > 0");

// Update the listing price
listings[nftAddress][tokenId].price = newPrice;

// Emit the event
emit ListingUpdated(nftAddress, tokenId, newPrice, msg.sender);
}»>

( , , ,
);
( , ,
) (nftAddress, tokenId) (nftAddress, tokenId) { // Cannot update the price to be < 0 (newPrice , "MRKT: Price must be > 0"); // Update the listing price listings[nftAddress][tokenId].price newPrice; // Emit the event (nftAddress, tokenId, newPrice, .);
}

Now for the fun part! purchaseListing This will involve an ETH transfer from the buyer to the seller, and an NFT transfer from the seller to the buyer. We will also add an event definition to signify the purchase.

( , , ,
);
( , ) (nftAddress, tokenId)
{ // Load the listing in a local copy Listing listing listings[nftAddress][tokenId]; // Buyer must have sent enough ETH (. listing.price, "MRKT: Incorrect ETH supplied");// Delete listing from storage, save some gas listings[nftAddress][tokenId]; // Transfer NFT from seller to buyer (nftAddress).( listing.seller, ., tokenId ); // Transfer ETH sent from buyer to seller ( , ) (listing.seller).{value: .}(); (sent, "Failed to transfer eth"); // Emit the event (nftAddress, tokenId, listing.seller, .);
}

This is it! Our smart contract is ready! The final code should look something like this

mapping(uint256 => Listing)) public listings;

modifier isNFTOwner(address nftAddress, uint256 tokenId) {
require(
IERC721(nftAddress).ownerOf(tokenId) == msg.sender,
"MRKT: Not the owner"
);
_;
}

modifier isNotListed(address nftAddress, uint256 tokenId) {
require(
listings[nftAddress][tokenId].price == 0,
"MRKT: Already listed"
);
_;
}

Про NFT:  Nft паков

modifier isListed(address nftAddress, uint256 tokenId) {
require(listings[nftAddress][tokenId].price > 0, "MRKT: Not listed");
_;
}

event ListingCreated(
address nftAddress,
uint256 tokenId,
uint256 price,
address seller
);

event ListingCanceled(address nftAddress, uint256 tokenId, address seller);

event ListingUpdated(
address nftAddress,
uint256 tokenId,
uint256 newPrice,
address seller
);

event ListingPurchased(
address nftAddress,
uint256 tokenId,
address seller,
address buyer
);

function createListing(
address nftAddress,
uint256 tokenId,
uint256 price
)
external
isNotListed(nftAddress, tokenId)
isNFTOwner(nftAddress, tokenId)
{
require(price > 0, "MRKT: Price must be > 0");
IERC721 nftContract = IERC721(nftAddress);
require(
nftContract.isApprovedForAll(msg.sender, address(this)) ||
nftContract.getApproved(tokenId) == address(this),
"MRKT: No approval for NFT"
);
listings[nftAddress][tokenId] = Listing({
price: price,
seller: msg.sender
});

emit ListingCreated(nftAddress, tokenId, price, msg.sender);
}

function cancelListing(address nftAddress, uint256 tokenId)
external
isListed(nftAddress, tokenId)
isNFTOwner(nftAddress, tokenId)
{
delete listings[nftAddress][tokenId];
emit ListingCanceled(nftAddress, tokenId, msg.sender);
}

function updateListing(
address nftAddress,
uint256 tokenId,
uint256 newPrice
) external isListed(nftAddress, tokenId) isNFTOwner(nftAddress, tokenId) {
require(newPrice > 0, "MRKT: Price must be > 0");
listings[nftAddress][tokenId].price = newPrice;
emit ListingUpdated(nftAddress, tokenId, newPrice, msg.sender);
}

function purchaseListing(address nftAddress, uint256 tokenId)
external
payable
isListed(nftAddress, tokenId)
{
Listing memory listing = listings[nftAddress][tokenId];
require(msg.value == listing.price, "MRKT: Incorrect ETH supplied");

delete listings[nftAddress][tokenId];

IERC721(nftAddress).safeTransferFrom(
listing.seller,
msg.sender,
tokenId
);
(bool sent, ) = payable(listing.seller).call{value: msg.value}("");
require(sent, "Failed to transfer eth");

emit ListingPurchased(nftAddress, tokenId, listing.seller, msg.sender);
}
}»>

// SPDX-License-Identifier: MIT ; ; { { price; seller; } ( ( Listing)) listings; ( , ) { ( (nftAddress).(tokenId) ., "MRKT: Not the owner" ); } ( , ) { ( listings[nftAddress][tokenId].price , "MRKT: Already listed" ); } ( , ) { (listings[nftAddress][tokenId].price , "MRKT: Not listed"); } ( , , , ); ( , , ); ( , , , ); ( , , , ); ( , , ) (nftAddress, tokenId) (nftAddress, tokenId) { (price , "MRKT: Price must be > 0"); nftContract (nftAddress); ( nftContract.(., ()) nftContract.(tokenId) (), "MRKT: No approval for NFT" ); listings[nftAddress][tokenId] ({ price: price, seller: . }); (nftAddress, tokenId, price, .); } ( , ) (nftAddress, tokenId) (nftAddress, tokenId) { listings[nftAddress][tokenId]; (nftAddress, tokenId, .); } ( , , ) (nftAddress, tokenId) (nftAddress, tokenId) { (newPrice , "MRKT: Price must be > 0"); listings[nftAddress][tokenId].price newPrice; (nftAddress, tokenId, newPrice, .); } ( , ) (nftAddress, tokenId) { Listing listing listings[nftAddress][tokenId]; (. listing.price, "MRKT: Incorrect ETH supplied"); listings[nftAddress][tokenId]; (nftAddress).( listing.seller, ., tokenId ); ( , ) (listing.seller).{value: .}(); (sent, "Failed to transfer eth"); (nftAddress, tokenId, listing.seller, .); }
}

Now, it’s time to deploy!

🚢 Shipping It

We will deploy this code on the Celo Alfajores Testnet, and will use Hardhat to do so. We need to get a few things in order to do this the right way.

  1. Get a private key that has testnet funds on it to deploy the contract
  2. Get an RPC URL for the Celo Testnet
  3. Use environment variables to store our private key and RPC Url
    1. Create a .env file
    2. Use dotenv package to read environment variables within Hardhat
  4. Configure hardhat.config.js and add the Alfajores testnet
  5. Write a deployment script for Hardhat to automate deploys

For the private key, you can either use the mobile wallet we set up earlier, or add the Alfajores Testnet to Metamask as a network using Chainlist and then requesting testnet tokens using the Celo Faucet.

So, let’s create a .env file within the hardhat folder. Replace the private key with your own.

 .env filePRIVATE_KEY=
RPC_URL=

// Initialize `dotenv` with the `.config()` function : // Environment variables should now be available// under `process.env` // Show an error if environment variables are missing "Missing PRIVATE_KEY environment variable" "Missing RPC_URL environment variable"// Add the alfajores network to the configuration : : : : : 

Once this is done, we can write our deployment script. Create a new file called deploy.js in hardhat/scripts.

process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});»>
 ethers // Load the NFT contract artifacts // Deploy the contract // Print the address of the NFT contract "Celo NFT deployed to:" // Load the marketplace contract artifacts // Deploy the contract // Wait for deployment to finish // Log the address of the new contract "NFT Marketplace deployed to:" 

Amazing! If you’ve done everything correctly, you should now be able to just deploy your contract.

npx hardhat run scripts/deploy.js --network alfajores

If you see an output that looks like this:

Celo NFT deployed to: 0xcC48dA1123dc9e7741FB4040E7A9E010664b51cb
NFT Marketplace deployed to: 0x9014DD98Cd14B26c76069356247cE6d762018220

You’re all set! You can look up your contract on CeloScan as well.

🌟 Next Steps

This level was all about the smart contract. Moving forward, we will develop the subgraph for this contract, and then finally develop the frontend for the dApp using Next.

To verify this level, submit your Marketplace contract address below and select the Celo Alfajores Testnet while doing so.

Improve this page

Add a description, image, and links to the

topic page so that developers can more easily learn about it.


Curate this topic

Improve this page

Add a description, image, and links to the

topic page so that developers can more easily learn about it.


Curate this topic

Add this topic to your repo

To associate your repository with the

topic, visit your repo’s landing page and select «manage topics.»

Add this topic to your repo

To associate your repository with the

topic, visit your repo’s landing page and select «manage topics.»

Files

Permalink

Failed to load latest commit information.

Latest commit message

This is a Next.js project. Full process and video lectures how to create the application can be found here: NFT Marketplace in React, Typescript & Solidity — Full Guide

Overview

Marketplace has dependencies on multiple technologies.

To run the app

  1. run npm install to install dependencies

NEXT_PUBLIC_NETWORK_ID=5777
NEXT_PUBLIC_TARGET_CHAIN_ID=1337
NEXT_PUBLIC_PINATA_DOMAIN=https://gateway.pinata.cloud
SECRET_COOKIE_PASSWORD={your custom at least 32 characters long password!}
PINATA_API_KEY={your api key from pinata}
PINATA_SECRET_API_KEY={your api secret key from pinata}
  • (your api pinata key has to allow pinFileToIPFS and pinJSONToIPFS rules)
  1. Then migrate a contract to Ganache, contract can be found in the contracts folder. It’s called NftMarket.sol
  • To migrate the contract run truffle migrate in the terminal while Ganache network is setup and running.

  • Do not forget to link trufle-config.js with Ganache, just go to config and click Add Project

  • keys.json must be created if you want to deploy to Ropsten, if not, just remove import of keys.json from trufle-config.js and also comment out ropsten configuration

  1. Now everything is setup and you can test out the app.
  • Run npm run dev in the terminal. App will run at localhost:3000
Оцените статью
NFT Эксперт