更改Google Chrome 用户文件存储目录User Data 最简单方法
当前位置正文更改Google Chrome 用户文件存储目录User Data 最简单方法 1.在你想要存放数据的盘符下创建文件夹,假设为E:\Google\Chrome 2.把已经存在的User Data数据复制到E:\Google\Chrome中 3.开始->附件->命令提示符(右键以管理员身份运行) 4.输入CD C:\Users\你的用户名\AppData\Local\Google\Chrome 5.输入RMDIR /S “User Data”,提示是否删除输入Y 6.输入MKLINK /J “User Data” “E:\Google\Chrome” 7.重启浏览器,大功告成。
a16z领投3000万美元的去中心化社交协议Farcaster教程
Step 1: 设置环境在编写代码之前,您需要设置一个 Node.js 环境,推荐使用 replit ,它是一个基于 IDE 进行编程的浏览器。 1.在 repli 上注册一个免费帐户并登录; 2.点击左上角的create创建;3.出现提示时选择 Node.js,然后点击Create Repl。还需要一个以太坊节点来与 Facaster Registry 合约对话。 建议使用 Alchemy 。 如果您是第一次注册,以下步骤可能会略有不同: 1.注册 Alchemy.com ,并登录。2.选择以太坊作为区块链,点击get started。3.team name和app name随便取,网络选择Rinkeby,点击Create APP。4.选择第一个免费的,点击continue。5.点击跳过。6.继续点击跳过。7.点击continue。8.随便输入什么,点击let‘s go。9.点击view details。10.点击view key。11.找到HTTP的URL,复制v2/后面那部分代码,将其保存在某个地方。12.切换回 Replit 并转到右侧窗格中的 Shell 选项卡并运行以...
更改Google Chrome 用户文件存储目录User Data 最简单方法
当前位置正文更改Google Chrome 用户文件存储目录User Data 最简单方法 1.在你想要存放数据的盘符下创建文件夹,假设为E:\Google\Chrome 2.把已经存在的User Data数据复制到E:\Google\Chrome中 3.开始->附件->命令提示符(右键以管理员身份运行) 4.输入CD C:\Users\你的用户名\AppData\Local\Google\Chrome 5.输入RMDIR /S “User Data”,提示是否删除输入Y 6.输入MKLINK /J “User Data” “E:\Google\Chrome” 7.重启浏览器,大功告成。
a16z领投3000万美元的去中心化社交协议Farcaster教程
Step 1: 设置环境在编写代码之前,您需要设置一个 Node.js 环境,推荐使用 replit ,它是一个基于 IDE 进行编程的浏览器。 1.在 repli 上注册一个免费帐户并登录; 2.点击左上角的create创建;3.出现提示时选择 Node.js,然后点击Create Repl。还需要一个以太坊节点来与 Facaster Registry 合约对话。 建议使用 Alchemy 。 如果您是第一次注册,以下步骤可能会略有不同: 1.注册 Alchemy.com ,并登录。2.选择以太坊作为区块链,点击get started。3.team name和app name随便取,网络选择Rinkeby,点击Create APP。4.选择第一个免费的,点击continue。5.点击跳过。6.继续点击跳过。7.点击continue。8.随便输入什么,点击let‘s go。9.点击view details。10.点击view key。11.找到HTTP的URL,复制v2/后面那部分代码,将其保存在某个地方。12.切换回 Replit 并转到右侧窗格中的 Shell 选项卡并运行以...
Share Dialog
Share Dialog

Subscribe to andrecronje

Subscribe to andrecronje
<100 subscribers
<100 subscribers
原文地址 :https://docs.alchemy.com/docs/how-to-build-an-nft-marketplace-from-scratch
请大家关注我的推特(twitter.com/SoullessL)和Link3(link3.to/caishen),获取最新的Alchemy小白教程。教程汇总链接(jayjiang.gitbook.io/web3book/alchemy-road-to-web3)。
大部分人应该已经添加过了,如果已经添加可以忽略
测试网络信息如下
Network Name: Goerli Test Network
RPC base URL: https://eth-goerli.alchemyapi.io/v2/{INSERT YOUR API KEY}
Chain ID: 5
Block Explorer URL: https://goerli.etherscan.io/
Symbol (Optional): ETH

登录(www.alchemy.com)其中{INSERT YOUR API KEY}需要修改为你的Api Key,如截图所示。


进入Alchemy官方的Github地址(https://github.com/OMGWINNING/NFT-Marketplace-Tutorial),点击Fork按钮,把官方的代码复制到你的Github里。%EF%BC%8C%E7%82%B9%E5%87%BBFork%E6%8C%89%E9%92%AE%EF%BC%8C%E6%8A%8A%E5%AE%98%E6%96%B9%E7%9A%84%E4%BB%A3%E7%A0%81%E5%A4%8D%E5%88%B6%E5%88%B0%E4%BD%A0%E7%9A%84Github%E9%87%8C%E3%80%82)

然后系统就会自动转跳到你的Github页面,像截图里的地方会是你的github名字,我们记录下自己项目的GitHub浏览器地址。
然后通过Gitpod打开项目,在浏览器输入 https://gitpod.io/#https://github.com/你的github名字/NFT-Marketplace-Tutorial 开打项目。

然后等待出现下面的窗口,你可以点击这个Open Browser,来预览我们项目。

然后会出来这样一个窗口,就说明我们的项目加载好了,我图里的图片还没完全加载完,可以忽略。

然后我们回到我们的Terminal窗口,同时按住Ctrl+C,取消程序的运行。

然后我们输入命令 npm install dotenv --save 安装一下dotenv环境

然后在Explorer窗体的空白处点击鼠标右键,弹出一个窗口,选择New File。



文件名字为.env,里面的内容为
REACT_APP_ALCHEMY_API_URL="" REACT_APP_PRIVATE_KEY="" 请记得把””替换成Achemy的Goerli网络的Https部分,而””需要替换成你的Metamask账号的的私钥(这边最好使用一个新的账号,防止私钥泄密,这边使用的账号可以和你领取NFT的账号不一样,所以完全可以使用新的好账号,记得转点测试的ETH到新账号当手续费就行。用完最后记得把你的私钥删除,更安全一点)。 然后我们进入 https://pinata.cloud 注册一个新的账号,然后进入https://app.pinata.cloud/keys,点击New Key,勾选Admin,输入Key name,点击Create Key,创建一个新的Key。在弹出的窗口里,记录对应的 API Key 和 API Secret。 REACT_APP_PINATA_KEY="<YOUR_PINATA_KEY>" REACT_APP_PINATA_SECRET="<YOUR_PINATA_SECRET>" 然后把pinata对应的KEY和SECRET替换""和"",并添加到.env文件里。 最终.env文件如上图所示,但是对应的Key都是你自己的。 贴上整体的.env文件内容,方便大家替换。 REACT_APP_ALCHEMY_API_URL="<YOUR_API_URL>" REACT_APP_PRIVATE_KEY="<YOUR_PRIVATE_KEY>" REACT_APP_PINATA_KEY="<YOUR_PINATA_KEY>" REACT_APP_PINATA_SECRET="<YOUR_PINATA_SECRET>" 然后我们找到hardhat.config.js文件,把里的内容替换为 require("@nomiclabs/hardhat-waffle"); require("@nomiclabs/hardhat-ethers"); const fs = require('fs'); // const infuraId = fs.readFileSync(".infuraid").toString().trim() || ""; require('dotenv').config(); task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { const accounts = await hre.ethers.getSigners(); for (const account of accounts) { console.log(account.address); } }); module.exports = { networks: { goerli: { url: process.env.REACT_APP_ALCHEMY_API_URL, accounts: [process.env.REACT_APP_PRIVATE_KEY] } }, solidity: { version: "0.8.4", settings: { optimizer: { enabled: true, runs: 200 } } } }; 打开Contracts文件夹下面的NFTMarketplace.sol 文件,替换全部内容为 //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "hardhat/console.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; contract NFTMarketplace is ERC721URIStorage { using Counters for Counters.Counter; //_tokenIds variable has the most recent minted tokenId Counters.Counter private _tokenIds; //Keeps track of the number of items sold on the marketplace Counters.Counter private _itemsSold; //owner is the contract address that created the smart contract address payable owner; //The fee charged by the marketplace to be allowed to list an NFT uint256 listPrice = 0.01 ether; //The structure to store info about a listed token struct ListedToken { uint256 tokenId; address payable owner; address payable seller; uint256 price; bool currentlyListed; } //the event emitted when a token is successfully listed event TokenListedSuccess ( uint256 indexed tokenId, address owner, address seller, uint256 price, bool currentlyListed ); //This mapping maps tokenId to token info and is helpful when retrieving details about a tokenId mapping(uint256 => ListedToken) private idToListedToken; constructor() ERC721("NFTMarketplace", "NFTM") { owner = payable(msg.sender); } function updateListPrice(uint256 _listPrice) public payable { require(owner == msg.sender, "Only owner can update listing price"); listPrice = _listPrice; } function getListPrice() public view returns (uint256) { return listPrice; } function getLatestIdToListedToken() public view returns (ListedToken memory) { uint256 currentTokenId = _tokenIds.current(); return idToListedToken[currentTokenId]; } function getListedTokenForId(uint256 tokenId) public view returns (ListedToken memory) { return idToListedToken[tokenId]; } function getCurrentToken() public view returns (uint256) { return _tokenIds.current(); } //The first time a token is created, it is listed here function createToken(string memory tokenURI, uint256 price) public payable returns (uint) { //Increment the tokenId counter, which is keeping track of the number of minted NFTs _tokenIds.increment(); uint256 newTokenId = _tokenIds.current(); //Mint the NFT with tokenId newTokenId to the address who called createToken _safeMint(msg.sender, newTokenId); //Map the tokenId to the tokenURI (which is an IPFS URL with the NFT metadata) _setTokenURI(newTokenId, tokenURI); //Helper function to update Global variables and emit an event createListedToken(newTokenId, price); return newTokenId; } function createListedToken(uint256 tokenId, uint256 price) private { //Make sure the sender sent enough ETH to pay for listing require(msg.value == listPrice, "Hopefully sending the correct price"); //Just sanity check require(price > 0, "Make sure the price isn't negative"); //Update the mapping of tokenId's to Token details, useful for retrieval functions idToListedToken[tokenId] = ListedToken( tokenId, payable(address(this)), payable(msg.sender), price, true ); _transfer(msg.sender, address(this), tokenId); //Emit the event for successful transfer. The frontend parses this message and updates the end user emit TokenListedSuccess( tokenId, address(this), msg.sender, price, true ); } //This will return all the NFTs currently listed to be sold on the marketplace function getAllNFTs() public view returns (ListedToken[] memory) { uint nftCount = _tokenIds.current(); ListedToken[] memory tokens = new ListedTokenUnsupported embed; uint currentIndex = 0; //at the moment currentlyListed is true for all, if it becomes false in the future we will //filter out currentlyListed == false over here for(uint i=0;i<nftCount;i++) { uint currentId = i + 1; ListedToken storage currentItem = idToListedToken[currentId]; tokens[currentIndex] = currentItem; currentIndex += 1; } //the array 'tokens' has the list of all NFTs in the marketplace return tokens; } //Returns all the NFTs that the current user is owner or seller in function getMyNFTs() public view returns (ListedToken[] memory) { uint totalItemCount = _tokenIds.current(); uint itemCount = 0; uint currentIndex = 0; //Important to get a count of all the NFTs that belong to the user before we can make an array for them for(uint i=0; i < totalItemCount; i++) { if(idToListedToken[i+1].owner == msg.sender || idToListedToken[i+1].seller == msg.sender){ itemCount += 1; } } //Once you have the count of relevant NFTs, create an array then store all the NFTs in it ListedToken[] memory items = new ListedTokenUnsupported embed; for(uint i=0; i < totalItemCount; i++) { if(idToListedToken[i+1].owner == msg.sender || idToListedToken[i+1].seller == msg.sender) { uint currentId = i+1; ListedToken storage currentItem = idToListedToken[currentId]; items[currentIndex] = currentItem; currentIndex += 1; } } return items; } function executeSale(uint256 tokenId) public payable { uint price = idToListedToken[tokenId].price; address seller = idToListedToken[tokenId].seller; require(msg.value == price, "Please submit the asking price in order to complete the purchase"); //update the details of the token idToListedToken[tokenId].currentlyListed = true; idToListedToken[tokenId].seller = payable(msg.sender); _itemsSold.increment(); //Actually transfer the token to the new owner _transfer(address(this), msg.sender, tokenId); //approve the marketplace to sell NFTs on your behalf approve(address(this), tokenId); //Transfer the listing fee to the marketplace creator payable(owner).transfer(listPrice); //Transfer the proceeds from the sale to the seller of the NFT payable(seller).transfer(msg.value); } //We might add a resell token function in the future //In that case, tokens won't be listed by default but users can send a request to actually list a token //Currently NFTs are listed by default } 然后我们打开Terminal,在里面输入 npx hardhat run scripts/deploy.js --network goerli 来部署我们的智能合约到goerli 测试网。 然后我们可以到src文件夹下找到Marketplace.json文件,里面的address就是我们部署的合约地址。然后我们可以通过
原文地址 :https://docs.alchemy.com/docs/how-to-build-an-nft-marketplace-from-scratch
请大家关注我的推特(twitter.com/SoullessL)和Link3(link3.to/caishen),获取最新的Alchemy小白教程。教程汇总链接(jayjiang.gitbook.io/web3book/alchemy-road-to-web3)。
大部分人应该已经添加过了,如果已经添加可以忽略
测试网络信息如下
Network Name: Goerli Test Network
RPC base URL: https://eth-goerli.alchemyapi.io/v2/{INSERT YOUR API KEY}
Chain ID: 5
Block Explorer URL: https://goerli.etherscan.io/
Symbol (Optional): ETH

登录(www.alchemy.com)其中{INSERT YOUR API KEY}需要修改为你的Api Key,如截图所示。


进入Alchemy官方的Github地址(https://github.com/OMGWINNING/NFT-Marketplace-Tutorial),点击Fork按钮,把官方的代码复制到你的Github里。%EF%BC%8C%E7%82%B9%E5%87%BBFork%E6%8C%89%E9%92%AE%EF%BC%8C%E6%8A%8A%E5%AE%98%E6%96%B9%E7%9A%84%E4%BB%A3%E7%A0%81%E5%A4%8D%E5%88%B6%E5%88%B0%E4%BD%A0%E7%9A%84Github%E9%87%8C%E3%80%82)

然后系统就会自动转跳到你的Github页面,像截图里的地方会是你的github名字,我们记录下自己项目的GitHub浏览器地址。
然后通过Gitpod打开项目,在浏览器输入 https://gitpod.io/#https://github.com/你的github名字/NFT-Marketplace-Tutorial 开打项目。

然后等待出现下面的窗口,你可以点击这个Open Browser,来预览我们项目。

然后会出来这样一个窗口,就说明我们的项目加载好了,我图里的图片还没完全加载完,可以忽略。

然后我们回到我们的Terminal窗口,同时按住Ctrl+C,取消程序的运行。

然后我们输入命令 npm install dotenv --save 安装一下dotenv环境

然后在Explorer窗体的空白处点击鼠标右键,弹出一个窗口,选择New File。



文件名字为.env,里面的内容为
REACT_APP_ALCHEMY_API_URL="" REACT_APP_PRIVATE_KEY="" 请记得把””替换成Achemy的Goerli网络的Https部分,而””需要替换成你的Metamask账号的的私钥(这边最好使用一个新的账号,防止私钥泄密,这边使用的账号可以和你领取NFT的账号不一样,所以完全可以使用新的好账号,记得转点测试的ETH到新账号当手续费就行。用完最后记得把你的私钥删除,更安全一点)。 然后我们进入 https://pinata.cloud 注册一个新的账号,然后进入https://app.pinata.cloud/keys,点击New Key,勾选Admin,输入Key name,点击Create Key,创建一个新的Key。在弹出的窗口里,记录对应的 API Key 和 API Secret。 REACT_APP_PINATA_KEY="<YOUR_PINATA_KEY>" REACT_APP_PINATA_SECRET="<YOUR_PINATA_SECRET>" 然后把pinata对应的KEY和SECRET替换""和"",并添加到.env文件里。 最终.env文件如上图所示,但是对应的Key都是你自己的。 贴上整体的.env文件内容,方便大家替换。 REACT_APP_ALCHEMY_API_URL="<YOUR_API_URL>" REACT_APP_PRIVATE_KEY="<YOUR_PRIVATE_KEY>" REACT_APP_PINATA_KEY="<YOUR_PINATA_KEY>" REACT_APP_PINATA_SECRET="<YOUR_PINATA_SECRET>" 然后我们找到hardhat.config.js文件,把里的内容替换为 require("@nomiclabs/hardhat-waffle"); require("@nomiclabs/hardhat-ethers"); const fs = require('fs'); // const infuraId = fs.readFileSync(".infuraid").toString().trim() || ""; require('dotenv').config(); task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { const accounts = await hre.ethers.getSigners(); for (const account of accounts) { console.log(account.address); } }); module.exports = { networks: { goerli: { url: process.env.REACT_APP_ALCHEMY_API_URL, accounts: [process.env.REACT_APP_PRIVATE_KEY] } }, solidity: { version: "0.8.4", settings: { optimizer: { enabled: true, runs: 200 } } } }; 打开Contracts文件夹下面的NFTMarketplace.sol 文件,替换全部内容为 //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "hardhat/console.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; contract NFTMarketplace is ERC721URIStorage { using Counters for Counters.Counter; //_tokenIds variable has the most recent minted tokenId Counters.Counter private _tokenIds; //Keeps track of the number of items sold on the marketplace Counters.Counter private _itemsSold; //owner is the contract address that created the smart contract address payable owner; //The fee charged by the marketplace to be allowed to list an NFT uint256 listPrice = 0.01 ether; //The structure to store info about a listed token struct ListedToken { uint256 tokenId; address payable owner; address payable seller; uint256 price; bool currentlyListed; } //the event emitted when a token is successfully listed event TokenListedSuccess ( uint256 indexed tokenId, address owner, address seller, uint256 price, bool currentlyListed ); //This mapping maps tokenId to token info and is helpful when retrieving details about a tokenId mapping(uint256 => ListedToken) private idToListedToken; constructor() ERC721("NFTMarketplace", "NFTM") { owner = payable(msg.sender); } function updateListPrice(uint256 _listPrice) public payable { require(owner == msg.sender, "Only owner can update listing price"); listPrice = _listPrice; } function getListPrice() public view returns (uint256) { return listPrice; } function getLatestIdToListedToken() public view returns (ListedToken memory) { uint256 currentTokenId = _tokenIds.current(); return idToListedToken[currentTokenId]; } function getListedTokenForId(uint256 tokenId) public view returns (ListedToken memory) { return idToListedToken[tokenId]; } function getCurrentToken() public view returns (uint256) { return _tokenIds.current(); } //The first time a token is created, it is listed here function createToken(string memory tokenURI, uint256 price) public payable returns (uint) { //Increment the tokenId counter, which is keeping track of the number of minted NFTs _tokenIds.increment(); uint256 newTokenId = _tokenIds.current(); //Mint the NFT with tokenId newTokenId to the address who called createToken _safeMint(msg.sender, newTokenId); //Map the tokenId to the tokenURI (which is an IPFS URL with the NFT metadata) _setTokenURI(newTokenId, tokenURI); //Helper function to update Global variables and emit an event createListedToken(newTokenId, price); return newTokenId; } function createListedToken(uint256 tokenId, uint256 price) private { //Make sure the sender sent enough ETH to pay for listing require(msg.value == listPrice, "Hopefully sending the correct price"); //Just sanity check require(price > 0, "Make sure the price isn't negative"); //Update the mapping of tokenId's to Token details, useful for retrieval functions idToListedToken[tokenId] = ListedToken( tokenId, payable(address(this)), payable(msg.sender), price, true ); _transfer(msg.sender, address(this), tokenId); //Emit the event for successful transfer. The frontend parses this message and updates the end user emit TokenListedSuccess( tokenId, address(this), msg.sender, price, true ); } //This will return all the NFTs currently listed to be sold on the marketplace function getAllNFTs() public view returns (ListedToken[] memory) { uint nftCount = _tokenIds.current(); ListedToken[] memory tokens = new ListedTokenUnsupported embed; uint currentIndex = 0; //at the moment currentlyListed is true for all, if it becomes false in the future we will //filter out currentlyListed == false over here for(uint i=0;i<nftCount;i++) { uint currentId = i + 1; ListedToken storage currentItem = idToListedToken[currentId]; tokens[currentIndex] = currentItem; currentIndex += 1; } //the array 'tokens' has the list of all NFTs in the marketplace return tokens; } //Returns all the NFTs that the current user is owner or seller in function getMyNFTs() public view returns (ListedToken[] memory) { uint totalItemCount = _tokenIds.current(); uint itemCount = 0; uint currentIndex = 0; //Important to get a count of all the NFTs that belong to the user before we can make an array for them for(uint i=0; i < totalItemCount; i++) { if(idToListedToken[i+1].owner == msg.sender || idToListedToken[i+1].seller == msg.sender){ itemCount += 1; } } //Once you have the count of relevant NFTs, create an array then store all the NFTs in it ListedToken[] memory items = new ListedTokenUnsupported embed; for(uint i=0; i < totalItemCount; i++) { if(idToListedToken[i+1].owner == msg.sender || idToListedToken[i+1].seller == msg.sender) { uint currentId = i+1; ListedToken storage currentItem = idToListedToken[currentId]; items[currentIndex] = currentItem; currentIndex += 1; } } return items; } function executeSale(uint256 tokenId) public payable { uint price = idToListedToken[tokenId].price; address seller = idToListedToken[tokenId].seller; require(msg.value == price, "Please submit the asking price in order to complete the purchase"); //update the details of the token idToListedToken[tokenId].currentlyListed = true; idToListedToken[tokenId].seller = payable(msg.sender); _itemsSold.increment(); //Actually transfer the token to the new owner _transfer(address(this), msg.sender, tokenId); //approve the marketplace to sell NFTs on your behalf approve(address(this), tokenId); //Transfer the listing fee to the marketplace creator payable(owner).transfer(listPrice); //Transfer the proceeds from the sale to the seller of the NFT payable(seller).transfer(msg.value); } //We might add a resell token function in the future //In that case, tokens won't be listed by default but users can send a request to actually list a token //Currently NFTs are listed by default } 然后我们打开Terminal,在里面输入 npx hardhat run scripts/deploy.js --network goerli 来部署我们的智能合约到goerli 测试网。 然后我们可以到src文件夹下找到Marketplace.json文件,里面的address就是我们部署的合约地址。然后我们可以通过
No activity yet