일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- web
- Programming
- NFT
- tcp
- web3.js
- 블록체인
- 솔리디티
- 이더리움
- 트랜잭션
- ethers
- Python
- JavaScript
- github
- erc
- ERC165
- Ethereum
- erc721
- MySQL
- solidity
- ERC20
- server
- truffle
- blockchain
- 네트워크
- git
- Docker
- 스마트 컨트랙트
- 제어의역전
- web3
- geth
- Today
- Total
멍개의 연구소
[ethereum] ERC721을 이용한 NFT 만들기 - 3편 본문
▶ ropsten 네트워크 배포
https://ropsten.etherscan.io/token/0x4fAb976447Abfab5ba35C94e298865409a9ddc6c
() Token Tracker | Etherscan
() Token Tracker on Etherscan shows the price of the Token $0.00, total supply 0, number of holders 1 and updated information of the token. The token tracker page also shows the analytics and historical data.
ropsten.etherscan.io
▶ ropsten 네트워크 배포 - NFT 생성기
https://inspiring-newton-bf922b.netlify.app
NFT Generator
inspiring-newton-bf922b.netlify.app
▶ solidity 0.5에서 0.8.9로 컨버팅
ERC721의 인터페이스가 아닌 mint 함수를 추상 컨트랙트를 통해 인터페이스를 제공하여 명확한 형태의 코드로 개선하였습니다.
https://github.com/Exchange-M/NFT-ERC721
GitHub - Exchange-M/NFT-ERC721: ERC721 for NFT
ERC721 for NFT. Contribute to Exchange-M/NFT-ERC721 development by creating an account on GitHub.
github.com
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import 'https://github.com/Exchange-M/NFT-ERC721/blob/master/ERC721.sol';
contract Minty_ERC721 is Minty, ERC721 {
// Counters.Counter 타입인 _ownedTokensCount[uint]가 library Counters에 정의된 increment(), decrement(), current()를 호출하기 위해 필요
using Counters for Counters.Counter;
function _mint(address to, uint256 tokenId) internal override {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_tokenOwner[tokenId] = to;
_ownedTokensCount[to].increment();
emit Transfer(address(0), to, tokenId);
}
}
contract CharactorByERC721 is Minty_ERC721 {
struct Charactor {
string name; // 캐릭터 이름
uint256 level; // 캐릭터 레벨
}
Charactor[] public charactors; // default: []
address public owner; // 컨트랙트 소유자
constructor () {
owner = msg.sender;
}
modifier isOwner() {
require(owner == msg.sender);
_;
}
// 캐릭터 생성
function mint(string memory name, address account) public isOwner {
uint256 cardId = charactors.length; // 유일한 캐릭터 ID
charactors.push(Charactor(name, 1));
_mint(account, cardId); // ERC721 소유권 등록
}
}