일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 정규표현식
- MySQL
- Algorithms
- 재귀함수
- 프로그래머스
- array.slice()
- 역행자
- select
- 블록체인
- Programmers
- 개발자의 책장
- Hackerrank
- 자바스크립트
- join
- Where
- SQL
- array
- 코딩테스트
- array.push()
- 알고리즘
- 최강의 인생
- 배열
- 코플릿
- 코딩공부
- for문
- 코드스테이츠
- 개발자_조이킴
- JavaScript
- Developer_JoyKim
- node.js
Archives
- Today
- Total
CodingSpace
블록체인/클레이튼 - KIP17_tokenURI 함수에 비밀(?) 본문
What:
- 기작성된 Solidity를 활용하여 NFT Minting 프로젝트를 수행중
- 필자는 NFT tokenURI를 KlaytnScope에서 조회할 수 있는 기능을 확인 및 검토하고 있었음
- Solidity 코드를 살펴봐도 NFT Mint 함수가 실행될 때 tokenURI를 설정하는 부분이 없었음
- 다만 setRevealedURI 함수를 통해 revealedURI 변수에 URI 값을 할당해줄 수 있었음
- 하지만 해당 URI가 특정 NFT와 mapping 되는 부분이 없어 매우 혼란스러웠음
Solved:
- Klaytnscope API에서 tokenURI 함수를 실행시켜 tokenURI 값을 조회하는 것 같음!
- 즉, tokenURI 형식만 맞추면 (tokenId가 입력되었을 때, 해당 tokenId와 매칭되는 URI를 반환하는 함수) 그림#2 처럼 Klaytnscope에서 tokenURI를 확인할 수 있는 것임!
// 문제의 Solidity 코드
function tokenURI(uint256 tokenId) public view returns (string memory) {
require(
_exists(tokenId),
"KIP17Metadata: URI query for nonexistent token"
);
if (revealed == false) {
string memory currentUnrevealedUri = _unrevealedURI();
return
bytes(currentUnrevealedUri).length > 0
? string(
abi.encodePacked(
currentUnrevealedUri,
String.uint2str(tokenId),
".json"
)
)
: "";
}
string memory currentRevealedURI = _revealedURI();
return
bytes(currentRevealedURI).length > 0
? string(
abi.encodePacked(
currentRevealedURI,
String.uint2str(tokenId),
".json"
)
)
: "";
}
References.
클레이스코프 (Baobab)
https://baobab.scope.klaytn.com/
체인의 정석 "ERC721) token URI에 대한 코드분석"
https://it-timehacker.tistory.com/230
For Developer.
- 잘못되거나 부족한 부분이 있다면 언제든지 댓글 부탁드립니다 :)
'블록체인' 카테고리의 다른 글
(니모닉 지갑 개발하기) Chapter1: 니모닉 구문 (mnemonic phrase) 생성 (0) | 2022.10.22 |
---|---|
[Blockchain] tokenURI 입력값을 주의하자! (feat. Opensea) (0) | 2022.09.04 |
블록체인/이더리움 - 용어 간단정리 (0) | 2022.07.26 |
블록체인 - KLAY 받기 (feat. Baobab) (0) | 2022.06.15 |
SmartContract / 스마트컨트랙트 (0) | 2022.04.12 |
Comments