#활용한 tool
Remix
AWS S3 버킷
openzeppelin
#작업순서
- Remix에서 openzeppelin library importing
- contract 작성
- compile 및 deploy
- 이미지 및 속성값 담은 properties.json 작성
- AWS S3 버킷에 properties.json 업로드
- json 파일의 url 바탕으로 minting
- openSea testnet에서 확인
#전체코드
contract part
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract MyNFTs is ERC721URIStorage, Ownable{
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() 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;
}
}
properties part
{
"name": "holyShit #1",
"description": "holy creature's shit is also holt",
"image": "https://pbs.twimg.com/profile_images/704509757877391360/PhH9dkJy_400x400.jpg",
"attributes": [
{
"trait_type": "Power",
"value": "Max"
}
]
}


#trouble shotting
- AWS S3에 올린 json 파일에 접근하기 위해서는 읽기 권한을 퍼블릭으로 바꿔줘야 함
- opensea testnet은 Rinkeby 네트워크만 지원
#추가로 구현할 기능
- 민팅가격설정
'TIL' 카테고리의 다른 글
| TIL) Ganache, Truffle, Hardhat, OpenZeppelin (2) | 2022.07.15 |
|---|---|
| TIL) Solidity 기본 문법: 변수 및 데이터 타입, 함수 (0) | 2022.07.15 |
| TIL) ERC-20 토큰 배포 및 추가기능 구현(OwnerHelper, TokenLock) (0) | 2022.07.15 |
| TIL) 이더리움 스마트 컨트랙트 가스비, 스마트 컨트랙트 활용 사례 (0) | 2022.07.07 |
| TIL) 블록체인과 튜링완전성 (2) | 2022.07.07 |