淺談 NFT

以及我ㄉ觀點

先打預防針

剛踏入鏈/幣圈 一個多月

約莫兩年經驗的軟體工程師

背景

如果有講錯請多多包涵,也歡迎大家分享交流

所以還是會穿插一些工程師視角

(因為也想知道工程端是怎麼實踐這些事)

拉回正題

先看定義

Non-Fungible Token(非質化代幣)

一種可以在鏈上交易的代幣格式,可夾帶著 metadata (ex: link, description)等資產相關資訊

並保有永久性、不可篡改性、真實性

 

 

 

而由於非質化的特性,幣與幣之間並不是等值的

 

阿如果連結的圖是放在第三方托管的話,

還是有可能被修改d

怎麼實現的? 基於 ERC 721

ERC 721 就是個開發 NFT 的協議

 而 ERC 20 就是開發比特幣、以太幣那種同質化幣種

阿所謂的協議如果用工程師的視角來看的話,就是當你在開發時時需要引用協議的 abstract class,這個 class 裡面已經定義好部分的 method 供開發者使用

 

pragma solidity ^0.4.20;

/// @title ERC-721 Non-Fungible Token Standard
/// @dev See https://eips.ethereum.org/EIPS/eip-721
///  Note: the ERC-165 identifier for this interface is 0x80ac58cd.
interface ERC721 /* is ERC165 */ {
    /// @dev This emits when ownership of any NFT changes by any mechanism.
    ///  This event emits when NFTs are created (`from` == 0) and destroyed
    ///  (`to` == 0). Exception: during contract creation, any number of NFTs
    ///  may be created and assigned without emitting Transfer. At the time of
    ///  any transfer, the approved address for that NFT (if any) is reset to none.
    event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);

    /// @dev This emits when the approved address for an NFT is changed or
    ///  reaffirmed. The zero address indicates there is no approved address.
    ///  When a Transfer event emits, this also indicates that the approved
    ///  address for that NFT (if any) is reset to none.
    event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);

    /// @dev This emits when an operator is enabled or disabled for an owner.
    ///  The operator can manage all NFTs of the owner.
    event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);

    /// @notice Count all NFTs assigned to an owner
    /// @dev NFTs assigned to the zero address are considered invalid, and this
    ///  function throws for queries about the zero address.
    /// @param _owner An address for whom to query the balance
    /// @return The number of NFTs owned by `_owner`, possibly zero
    function balanceOf(address _owner) external view returns (uint256);

    /// @notice Find the owner of an NFT
    /// @dev NFTs assigned to zero address are considered invalid, and queries
    ///  about them do throw.
    /// @param _tokenId The identifier for an NFT
    /// @return The address of the owner of the NFT
    function ownerOf(uint256 _tokenId) external view returns (address);

    /// @notice Transfers the ownership of an NFT from one address to another address
    /// @dev Throws unless `msg.sender` is the current owner, an authorized
    ///  operator, or the approved address for this NFT. Throws if `_from` is
    ///  not the current owner. Throws if `_to` is the zero address. Throws if
    ///  `_tokenId` is not a valid NFT. When transfer is complete, this function
    ///  checks if `_to` is a smart contract (code size > 0). If so, it calls
    ///  `onERC721Received` on `_to` and throws if the return value is not
    ///  `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
    /// @param _from The current owner of the NFT
    /// @param _to The new owner
    /// @param _tokenId The NFT to transfer
    /// @param data Additional data with no specified format, sent in call to `_to`
    function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;

    /// @notice Transfers the ownership of an NFT from one address to another address
    /// @dev This works identically to the other function with an extra data parameter,
    ///  except this function just sets data to "".
    /// @param _from The current owner of the NFT
    /// @param _to The new owner
    /// @param _tokenId The NFT to transfer
    function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;

    /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
    ///  TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
    ///  THEY MAY BE PERMANENTLY LOST
    /// @dev Throws unless `msg.sender` is the current owner, an authorized
    ///  operator, or the approved address for this NFT. Throws if `_from` is
    ///  not the current owner. Throws if `_to` is the zero address. Throws if
    ///  `_tokenId` is not a valid NFT.
    /// @param _from The current owner of the NFT
    /// @param _to The new owner
    /// @param _tokenId The NFT to transfer
    function transferFrom(address _from, address _to, uint256 _tokenId) external payable;

    /// @notice Change or reaffirm the approved address for an NFT
    /// @dev The zero address indicates there is no approved address.
    ///  Throws unless `msg.sender` is the current NFT owner, or an authorized
    ///  operator of the current owner.
    /// @param _approved The new approved NFT controller
    /// @param _tokenId The NFT to approve
    function approve(address _approved, uint256 _tokenId) external payable;

    /// @notice Enable or disable approval for a third party ("operator") to manage
    ///  all of `msg.sender`'s assets
    /// @dev Emits the ApprovalForAll event. The contract MUST allow
    ///  multiple operators per owner.
    /// @param _operator Address to add to the set of authorized operators
    /// @param _approved True if the operator is approved, false to revoke approval
    function setApprovalForAll(address _operator, bool _approved) external;

    /// @notice Get the approved address for a single NFT
    /// @dev Throws if `_tokenId` is not a valid NFT.
    /// @param _tokenId The NFT to find the approved address for
    /// @return The approved address for this NFT, or the zero address if there is none
    function getApproved(uint256 _tokenId) external view returns (address);

    /// @notice Query if an address is an authorized operator for another address
    /// @param _owner The address that owns the NFTs
    /// @param _operator The address that acts on behalf of the owner
    /// @return True if `_operator` is an approved operator for `_owner`, false otherwise
    function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}

ERC 721 interface

//Contract based on https://docs.openzeppelin.com/contracts/3.x/erc721
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.3;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";


contract MyNFT is ERC721, Ownable {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() public ERC721("MyNFT", "NFT") {}

    function mintNFT(address recipient, string memory tokenURI)
        public onlyOwner
        returns (uint256)
    {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(recipient, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }
}

所以如果要做一個 NFT 大概會像這樣

Opensea

那如果單看協議,ERC 20 和 ERC 721 差在哪?

來看看 method 上面的定義

簡單來說 transferFrom 這個 method 被使用就會

ERC 20

from address:   - x token

to address:       + x token

ERC 721

釐清一些基本定義後,我們來看看

NFT 的價值

NFT 價值 = Intrinsic Value (內在價值)+ Utility Value (使用價值) + Premium (溢價)

目前的 NFT 類資產大多數的價值是來自於「溢價」,「內在價值」和「使用價值」相對比較低,甚至爲 0,換句話說就是沒什麼基本面

NFT project 只是科技菁英們的多層式傳銷

透過創造社群共同認同感

以及拉新下線來不斷炒高 NFT 價格

2021/12/16

這樣有不好嗎?其實也未必

價值確實本來就是由社群共識擬定的

(ex 線上遊戲虛寶)

但我只想知道有沒有感覺更實際的應用?

但在此之前我們還是先來看看目前有哪些應用

複習一下有哪些 NFT project

NFT Project

以及小故事

Collection

Social Proof

cyrpto punk

cyrpto phunk

購買NFT數位藝術品,

不代表你擁有作品的「所有權」和「著作權」

實驗

跟大多數的實驗藝術一樣,敬佩但我跟不上

Game/Metaverse

Membership

透過 NFT 入會,進而得到高價值資訊

https://www.ptt.cc/bbs/DigiCurrency/M.1639202802.A.7D0.html

例如一開始就限定發行數量、盲盒、burn、 nft 碎片化

應用除了前面所提到,這交易的過程也有很多玩法,

這些玩法可能是為了趣味性、減少手續費、想辦法增加稀缺性等等

盲盒(blind box)

盲盒(blind box)

abstract contract BaseERC721BlindBox is BaseERC721 {
    using Strings for uint256;
    bool private _blindBoxOpened = false;
    string private _blindTokenURI =
        "ipfs://QmexqcLDvoP6HCTtSGumG3yzhZdH8guvV3z3kReCvf2QKn";
    function _isBlindBoxOpened() internal view returns (bool) {
        return _blindBoxOpened;
    }
    function setBlindBoxOpened(bool _status) public {
        require(
            hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),
            "BaseERC721BlindBox: only admin can do this action"
        );
        _blindBoxOpened = _status;
    }
    // this function controls how the token URI is constructed
    function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI query for nonexistent token"
        );
        if (_blindBoxOpened) {
            string memory baseURI = _baseURI();
            return
                bytes(baseURI).length > 0
                    ? string(
                        abi.encodePacked(baseURI, tokenId.toString(), ".json")
                    )
                    : "";
        } else {
            return _blindTokenURI;
        }
    }
}

還有 ntf 借貸等等之後再提

目前乍看之下,大部分的應用都還很虛

就是爛

但我自己覺的 NFT 還是很有價值的技術手段,只是當前的載體/應用還不盡成熟

NFT 本身的價值個人認為有二

1. 不可偽證性(資產上鏈)

2. 原創者可抽取版稅

上鏈後雖然還是要透過第三方的機構取作認證,但至少可以確保來源、交易對象等資訊不會被篡改

數位資產

將合約、權杖等重要資訊進行數位資產化,傳統作法無法輕易的保障資料來源的可靠性

任何會員或訂票系統

(演唱會、訂房、球賽)

  • 不可偽證性很好作為會員/門票的憑證
  • 也可以利用制定智能條約,禁止其在二級市場做交易,或是抽取版稅

(前提是錢包與會員等綁定也要先做好)

但這種 to C 端的服務會遇到什麼困難?

上手不易(創錢包,出入金,選鏈......

解決之道有兩種

教育市場,降低門檻

教育市場

降低門檻

錢包降低上手門檻

 (qubic, blocto......etc)

就如前面提到的,因為這些新知識所造成的門檻

目前市場上大部分項目還是幣圈人在自爽

NFT 只是技術手段,不是目的,否則就是本末倒置,爲了 NFT 而 NFT 毫無意義。

就醬 感謝大家

REF

淺談 NFT

By Jay Chou

淺談 NFT

  • 461