2. Deploying Smart Contract
You can use Remix Online IDE or use truffle to deploy above MyERC721Card smart contract.
2.1 Deploying smart contract using Remix Online IDE
Please visit Klaytn Plugin for Remix and create a
MyERC721Cardcontract. 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임을 보여줍니다.
2.2 Deploying smart contract using truffle
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입니다.
Last updated
Was this helpful?