Skip to content

Commit

Permalink
feat: add contract code
Browse files Browse the repository at this point in the history
  • Loading branch information
tingzhao.ytz committed Mar 15, 2024
1 parent 906272f commit c6b9b50
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions 07_ContractDev/MyToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC721, Ownable {
uint256 private _nextTokenId = 0;

constructor()
ERC721("MyToken", "MTK")
Ownable(msg.sender)
{}

function mint(uint256 quantity) public payable {
require(quantity == 1, "quantity must be 1");
require(msg.value == 0.01 ether, "must pay 0.01 ether");
uint256 tokenId = _nextTokenId++;
_mint(msg.sender, tokenId);
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DApp 开发极简入门

**第 6 讲:Next.js 部署**[教程](./06_NextJS/readme.md)

**第 7 讲:合约开发和测试**[教程](./07_ContractDev/readme.md)
**第 7 讲:合约开发和测试**[教程](./07_ContractDev/readme.md) | [代码](./07_ContractDev/MyToken.sol)

**第 8 讲:合约部署**[教程](./08_ContractDeploy/readme.md)

Expand Down

0 comments on commit c6b9b50

Please sign in to comment.