Alchemyのチュートリアルを見ながらやりました。
Openzeppelin Wizard
Openzeppelin Wizardにアクセス
https://wizard.openzeppelin.com/
ERC721 のタブをクリックし、
トークンの名前を入力 する・
私の名前 Tatsuya トークン 「TTY」 にした。
FEATURES の設定はよく分からないので、 Alchemyのサイトの例のとおりにした。
Remixが立ち上がる。
Remix
Openzeppelin Wizardで作成されたコードが自動的に移記されている。
contract-98fa00c16a.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts@5.0.0/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@5.0.0/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts@5.0.0/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts@5.0.0/access/Ownable.sol";
contract Tatsuya is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable {
uint256 private _nextTokenId;
constructor(address initialOwner)
ERC721("Tatsuya", "TTY")
Ownable(initialOwner)
{}
function safeMint(address to, string memory uri) public onlyOwner {
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
}
// The following functions are overrides required by Solidity.
function _update(address to, uint256 tokenId, address auth)
internal
override(ERC721, ERC721Enumerable)
returns (address)
{
return super._update(to, tokenId, auth);
}
function _increaseBalance(address account, uint128 value)
internal
override(ERC721, ERC721Enumerable)
{
super._increaseBalance(account, value);
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable, ERC721URIStorage)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
DEPLOY & RUN TRANSACTION に移動
- ENVIRONMENT : Injected Web3
MetaMask が立ち上がる。 - CONTRACT : さっき作ったコントラクト
- 最初にいれるウォレットのアドレス
4. Deploy をクリック
コントラクトが作成される
以上