반업주부의 일상 배움사

블록체인 하나씩 알아보기 :: ERC721 본문

IT 인터넷/Blockchain

블록체인 하나씩 알아보기 :: ERC721

Banjubu 2022. 7. 19. 17:15
반응형

 

코인은 만들었고요.

2022.07.19 - [IT 인터넷/Blockchain] - 블록체인 하나씩 알아보기 :: ERC20

 

블록체인 하나씩 알아보기 :: ERC20

mint와 burn을 제공하는 간단한 것부터 해볼게요. BanjubuCoin.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/c..

banjubu.tistory.com

 

NFT(ERC721)도 mint, burn이 가능한 간단한 버전을 생성할게요.

 

BanjubuNFT.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

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

contract BanjubuNFT is ERC721, ERC721Burnable, Ownable {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIdCounter;

    constructor() ERC721("BanjubuNFT", "BJBNFT") {}

    function safeMint(address to) public onlyOwner {
        uint256 tokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();
        _safeMint(to, tokenId);
    }
}

 

Rinkeby에 올렸어요.

https://rinkeby.etherscan.io/address/0x74941E644f0fd08a7Bc5C7D7CdA9B88e1b8A8C55

 

BanjubuNFT | Address 0x74941E644f0fd08a7Bc5C7D7CdA9B88e1b8A8C55 | Etherscan

The Contract Address 0x74941E644f0fd08a7Bc5C7D7CdA9B88e1b8A8C55 page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on Etherscan.

rinkeby.etherscan.io

 

0x3ed...에게 하나를 발행할게요.

하나 더 발행할게요.

 

0x3ed...에게 두 개가 발행됐네요.

 

이제 없애볼게요. (burn)

자신의 NFT는 자신만 없앨 수 있어요.

 

처음 발급 받았던 NFT를 없앴어요.

주의할건 0번째를 없애도 1번째에 있는게 앞으로 당겨지진 않아요.

고유한 토큰 ID이기 때문이에요.

 

 

이제 마켓을 만들어서 NFT를 등록하고 판매해볼게요.

 

 

 

영어, 중국어 공부중이신가요?

홈스쿨 교재. 한 권으로 가족 모두 할 수 있어요!

 

한GLO 미네르바에듀 : 네이버쇼핑 스마트스토어

한글로 영어가 된다?! 한글로[한GLO]는 영어 중국어 일어 러시아어 스페인어가 됩니다!!

smartstore.naver.com

 

반응형
LIST
Comments