ESSAY / NOTE
预设ERC721合约创建方法
Hi @naszam,
Welcome to the community
One option (depending on your requirements) is to deploy the Preset contract as is.
Similarly to how we can deploy the ERC20 preset: Create an ERC20 without writing Solidity, using OpenZeppelin CLI 7
We can copy the build artifacts and deploy using OpenZeppelin CLI (or Truffle).
Alternatively, if you want to build on top of the ERC721 preset you can inherit as you have done.
https://forum.openzeppelin.com/t/erc721presetminterpauserautoid-constructor-implementation/2766/3
One option (depending on your requirements) is to deploy the Preset contract as is.
Similarly to how we can deploy the ERC20 preset: Create an ERC20 without writing Solidity, using OpenZeppelin CLI 7
We can copy the build artifacts and deploy using OpenZeppelin CLI (or Truffle).
Copy build artifacts
$ mkdir -p build/contracts/
$ cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/
Deploy ERC721PresetMinterPauserAutoId
$ npx oz deploy
No contracts found to compile.
? Choose the kind of deployment regular
? Pick a network development
? Pick a contract to deploy ERC721PresetMinterPauserAutoId
? name: string: My Token
? symbol: string: MYT
? baseURI: string: https://example.com/token/
✓ Deployed instance of ERC721PresetMinterPauserAutoId
0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab
Alternatively, if you want to build on top of the ERC721 preset you can inherit as you have done.
MyToken.sol
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/presets/ERC721PresetMinterPauserAutoId.sol";
contract MyToken is ERC721PresetMinterPauserAutoId {
constructor() public ERC721PresetMinterPauserAutoId("My Token", "MYT", "https://example.com/token/") {
}
}