Skeleton and JavaScript Architecture
Trong chủ đề này, bạn sẽ tìm hiểu về kiến trúc cơ bản đằng sau một NFT contract mà bạn sẽ develop khi tham gia serie "Từ Zero đến Hero" này. You'll discover the contract's layout and you'll see how the JavaScript files are structured in order to build a feature-complete smart contract.
Giới thiệu
Hướng dẫn này trình bày bộ khung mã nguồn cho NFT smart contract và cấu trúc file của nó. You'll find how all the functions are laid out as well as the missing JS code that needs to be filled in. Once every file and function has been covered, you'll go through the process of building the mock-up contract to confirm that everything is working correctly.
Cấu trúc file
Following a regular JavaScript project, the file structure for this smart contract has:
package.json
file to define the packages and scripts used in the project.src
folder where all the JavaScript source files are storedbuild
folder where the compiledwasm
will output to.
Các file source
File | Mô tả |
---|---|
approval.ts | Has the internal functions that controls the access and transfers of non-fungible tokens. |
enumeration.ts | Contains the internal methods to query for NFT tokens and their owners. |
index.ts | Holds the exposed smart contract functions. |
metadata.ts | Defines the token and metadata structures. |
mint.ts | Contains the internal token minting logic. |
nft_core.ts | Has the internal core logic that allows you to transfer NFTs between users. |
royalty.ts | Contains the internal payout-related functions. |
nft-tutorial-js
└── src
market-contract
nft-contract
├── approval.ts
├── enumeration.ts
├── index.ts
├── metadata.ts
├── mint.ts
├── nft_core.ts
└── royalty.ts
Hãy khám phá code trong GitHub repository. :::