10

NFT 開發實戰!基礎智能合約入門 (1)

 2 years ago
source link: https://blog.niclin.tw/2022/02/01/nft-smart-contract-1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

區塊鏈從早期的主流幣買賣,到後來遍地開花的 ERC-20 代幣大戰

又再次進化來炒 ERC-721 的 NFT 了

這篇文章主要紀錄 NFT 在目前主流的玩法是如何透過智能合約去開發的技術細節

以目前主流的 NFT 煉金流程來說,撇除行銷以外,精簡後留下關於技術的部分大致如下

  1. 使用者打開網頁,按下 Mint 可以連動 metamask 搶購你的 NFT 盲盒
  2. 等時間到在打開盲盒顯示抽到的 NFT 內容

如果你覺得筆記不好懂,也可以試試看我放在 Youtube 上的影片

預期完成目標

為了達到以上兩個行為的 user story,我將目標拆為以下的三個部分來進行實作

Part 1 合約部分

  1. 建立 ETH 互動的智能合約
  2. NFT 要能夠被 mint
  3. NFT 要能夠設置總量
  4. NFT 要能夠設定每個地址最大持有量
  5. NFT 要能夠限制單次 Mint 量
  6. NFT 要能夠設定公開販售開關

Part 2 圖片部分

  1. 如何快速製作多種拼圖及 meta 資料
  2. 如何上傳到 IPFS

Part 3 網站部分

  1. 要能夠寫一個網站點擊開啟連接 MetaMask
  2. 網站要能夠按下按鈕 Mint 我們做的 NFT 合約

確定好要完成的目標之後,我們要先準備相關的環境

Step 1 安裝 Metamask 並搞到測試的 ETH

https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn

裝完之後開啟測試模式

設定→ 進階 → Show test networks

將節點切到 Rinkeby 網路

截圖 2022-01-20 上午10.49.49.png

獲取開發用的測試 ETH

Step 2 安裝 node

不知道怎麼裝 node 可以參考

https://nodejs.org/en/download/

https://medium.com/彼得潘的-swift-ios-app-開發問題解答集/在-mac-安裝-node-js-npm-c94e33b5cd86

我習慣用 Yarn 請也一起安裝

npm install --global yarn

Step 3 安裝 remixd

https://remix-ide.readthedocs.io/en/latest/remixd.html

npm install -g @remix-project/remixd

本系列其他文章


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK