构建与优化 NFT 市场智能合约
一、创建 Ape 项目
首先,我们要创建一个 Ape 项目,具体操作步骤如下:
$ python3 -m venv .venv
(.venv) $ pip install eth-ape'[recommended-plugins]'==0.7.23
(.venv) $ mkdir nft_marketplace
(.venv) $ cd nft_marketplace
(.venv) $ ape init
# 输入项目名称:NFT Marketplace
成功后,“NFT Marketplace” 会被写入 ape-config.yaml 文件。
二、编写智能合约
在 contracts 文件夹中创建一个名为 NFTMarketplace.vy 的智能合约文件,并添加以下代码:
#pragma version ^0.3.0
interface ERC721_Interface:
def transferFrom(_from: address, _to: address, _tokenId: uint256): nonpayable
def ownerOf(_tokenId: uint256) -> address: view
pragma 行指定该智能合约只能使用 Vyp
超级会员免费看
订阅专栏 解锁全文
1223

被折叠的 条评论
为什么被折叠?



