ERC721PresetMinterPauserAutoId constructor implementation

I’m inheriting ERC721PresetMinterPauserAutoId.sol in my contract and trying to compile, I’m getting the following:
Contract “Test” should be marked as abstract.
contract Test is ERC721PresetMinterPauserAutoId {
^ (Relevant source part starts here and spans across multiple lines).
@openzeppelin/contracts/presets/ERC721PresetMinterPauserAutoId.sol:40:5: Missing implementation:
constructor(string memory name, string memory symbol, string memory baseURI) public ERC721(name, symbol) {
^ (Relevant source part starts here and spans across multiple lines).
:computer: Environment

OpenZeppelin v3.0.1
Truffle v5.1.24
Ganache-cli v6.9.1

:memo:Details

I would like to know how and where initialise name, symbol and baseURI, cause the docs indicates that should be done inside the constructor parameter but I’m getting errors like expeting “,”
Also, when trying adding a constructor, when compiling I’m asked to mark the contract abstract
:1234: Code to reproduce

pragma solidity 0.6.6;

import "@openzeppelin/contracts/presets/ERC721PresetMinterPauserAutoId.sol";

contract Test is ERC721PresetMinterPauserAutoId {

}
1 Like

I’ve tried the following and it compiles:

pragma solidity 0.6.6;

import “@openzeppelin/contracts/presets/ERC721PresetMinterPauserAutoId.sol”;

contract Test is ERC721PresetMinterPauserAutoId {
constructor() 
ERC721PresetMinterPauserAutoId("Name", "SYMBOL", "baseURI")
public {}

}
1 Like

Hi @naszam,

Welcome to the community :wave:

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

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/") {
    }
}
1 Like

Thanks @abcoathup!!!

1 Like