Created
January 18, 2022 13:41
-
-
Save DownyBehind/2df0f0c63b990888ed646f13c832fb5a to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.6+commit.b259423e.js&optimize=false&runs=200&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Klaytn IDE uses solidity 0.4.24 0.5.6 versions. | |
pragma solidity >=0.4.24 <=0.5.6; | |
contract Practice { | |
uint256 private totalSupply = 10; | |
string public name = "KlayLion"; | |
address public owner; // contract deployer | |
mapping(uint256 => string) public tokenURIs; // key - value type declare | |
// mint(tokenId, uri, owner) : 발행 | |
// transferFrom(from, to, tokenId) : 전송 | |
constructor () public { | |
owner = msg.sender; // 생성자는 conract 배포 시 실행, 배포자의 주소를 owner에 저장 | |
} | |
function getTotalSupply() public view returns (uint256) { | |
return totalSupply + 1000000; | |
} | |
function setTotalSupply(uint256 newSupply) public { | |
require(owner == msg.sender, 'Not owner'); // msg.sender가 owner랑 같을 때만 다음 줄 실행, 그렇지 않으면 err msg 띄움 | |
totalSupply = newSupply; | |
} | |
function setTokenUri(uint256 id, string memory uri) public { // memory는 좀 긴 타입의 데이터를 표시할 떄 쓴다. | |
tokenURIs[id] = uri; // mapping | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment