2. Deploying Smart Contract
Last updated
Was this helpful?
Last updated
Was this helpful?
You can use Remix Online IDE or use truffle to deploy above MyERC721Card
smart contract.
Please visit Klaytn Plugin for Remix and create a MyERC721Card
contract. The complete source code is given at Writing ERC-721 Smart Contract.
Create an account to deploy the contract with.
If you do not have an account yet, create one at https://baobab.wallet.klaytn.foundation/create or https://toolkit.klaytn.foundation/account/accountKeyLegacy.
Get some test KLAY from the faucet - https://baobab.wallet.klaytn.foundation/faucet
아래와 같이 MyERC721Card.sol
를 배포합시다.
이제 MyERC721
가 활성화되었습니다! ERC-721을 호환하는 대체 불가능한 토큰인 카드를 발행하고 전송할 수 있습니다.
아래와 같이 두 카드, 즉 King
과 Queen
카드를 0x2645BA5Be42FfEe907ca8e9d88f6Ee6dAd8c1410
계정에 대해 발행해봅시다.
이제 우리는 두 카드를 발행했고, 이들 MyERC721Card
대체 불가능한 토큰의 상태를 확인해봅시다.
balanceOf
는 계정 0x2645BA5Be42FfEe907ca8e9d88f6Ee6dAd8c1410
가 두 카드를 가졌음을 보여줍니다.
파라미터 1
인 cards
는 토큰 ID가 1
인 MyERC721Card
가 레벨 1의 Queen
임을 보여줍니다.
파라미터 0
인 ownerOf
는 토큰 ID가 0
인 MyERC721Card
의 소유자가 0x2645BA5Be42FfEe907ca8e9d88f6Ee6dAd8c1410
임을 보여줍니다.
You should have installed node.js in your environment. Please take a look at Installing Node.js via package manager to install node.js using package manager in various environment.
이제 스마트 컨트랙트를 배포하는 데 필요한 truffle 및 caver-js를 설치했습니다.
truffle
과 스마트 컨트랙트 MyERC721Card.sol
을 준비합시다.
Now you will have following directory structures.
MyERC721Card.sol
를 작성하고 contracts
디렉토리에 위치시킨 후, 디렉토리 구조는 다음과 같을 것입니다.
Now you will have following directory structures.
또한, MyERC721Card
컨트랙트를 배포하기 위해 아래와 같이 1_initial_migration.js
를 편집하세요.
또한 Klaytn 네트워크에 스마트 컨트랙트를 배포하기 위해 truffle-config.js
를 구성해야 합니다. 이는 트러플을 사용하여 스마트 컨트랙트 배포 에 설명된 순서와 동일합니다.
이제 모두 준비되었습니다. 다음 명령을 사용해 MyERC721Card.sol
을 배포합시다.
MyERC721Card
를 배포하기 위한 트랜잭션 해시는 0x1571e80552dab1d67260e8914e06d9b16ccae16fb698c750f6a09aab12517bc1
이며 MyERC721Card
의 주소는 0xc3d282926871c505f334d0f2c85ad52758347831
입니다.