igdiaz
November 25, 2021, 10:15pm
1
I want to create a smart contract for minting NFTs in Open Sea, very basic. Anyway, I´m struggling.
I can´t put name to new token, I receive this error:
project:/contracts/AxolotolImperium.sol:17:32: TypeError: Wrong argument count for modifier invocation: 2 arguments given but expected 0.
constructor() internal ERC721 ("AxolotlImperium", "AXOL") {
^--------------------------------^
In other hand, how do I read the images in my server, assign its non fungible number and upload it to Open Sea?
Code to reproduce
pragma solidity >=0.5.16 <0.9.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/ownership/Ownable.sol";
contract AxolotolImperium is Ownable, ERC721 {
struct Metadata {
uint8 color;
string tittle;
}
mapping (uint256 => Metadata) id_to_date;
string private _currentBaseURI;
constructor() internal ERC721 ("AxolotlImperium", "AXOL") {
}
}
Environment
Truffle
Amxx
November 26, 2021, 2:39pm
2
Hello @igdiaz
What version of Solidity are you using. When I try to compile your code in Remix. I get other errors:
import "@openzeppelin/contracts/ownership/Ownable.sol";
is not a valid path in current version of OZ contracts
internal constructor is also an old syntax. Solidity 0.8.0 uses the abstract contract
syntax instead of constructor visibility.
I would recommend you update your compiler to 0.8.x and OZ to 4.4.0
1 Like
igdiaz
November 26, 2021, 7:52pm
3
Hi Amxx,
Thanks, I´m using the next:
Truffle v5.4.22 (core: 5.4.22)
Solidity v0.5.16 (solc-js)
Node v14.17.1
Web3.js v1.5.3
I tried to unistall Truffle and Solidity, install again and it still being the same version, is that the latest? Or how do I install the 0.8.0?
igdiaz
December 1, 2021, 2:04pm
4
Amxx:
abstract contract
Hi Amxx,
i just updated to Solidity 0.8.3 and OZ 4.4.0 upgradeable. I still can´t name the token, I have this error:
TypeError: Wrong argument count for modifier invocation: 2 arguments given but expected 0.
--> project:/contracts/AxolotlImperium.sol:17:23:
|
17 | constructor() ERC721Upgradeable ("AxolotlImperium", "AXOL") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
My code is the next one:
pragma solidity >=0.4.22 <0.9.0;
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
contract AxolotlImperium is OwnableUpgradeable, ERC721Upgradeable {
struct Metadata {
uint8 color;
string tittle;
}
mapping (uint256 => Metadata) id_to_date;
string private _currentBaseURI;
constructor() ERC721Upgradeable ("AxolotlImperium", "AXOL") {
}
}
The code you shared compiles. Double check you have the right dependencies installed.
igdiaz
December 3, 2021, 2:49am
6
Hi Frangio,
With dependencies, do you mean Truffle, Solidity, and OpenZeppelin? Or do I have to install something else?
igdiaz
December 3, 2021, 2:51am
7
I´m getting this:
TypeError: Wrong argument count for modifier invocation: 2 arguments given but expected 0.
--> project:/contracts/AxolotlImperium.sol:17:23:
|
17 | constructor() ERC721Upgradeable ("AxolotlImperium", "AXOL") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@igdiaz My bad, not sure how I got the code to compile before.
The error is that you're using upgradeable contracts but using the constructor. Upgradeable contracts don't have a constructor, they have initializer functions. You should read the docs about this , and also take a look at the code generated by Contracts Wizard when you select upgradeability.
igdiaz
December 8, 2021, 7:25pm
9
Hi Frangio,
Thank you so much, I will check those docs.
igdiaz
December 9, 2021, 1:14am
10
Hi Frangio,
The solution was to erase the Open Zeppelin upgradeable folder and install the normal contracts:
npm install @openzeppelin/contracts
These are my current versions:
Truffle v5.4.22 (core: 5.4.22)
Solidity - 0.8.3 (solc-js)
Node v14.17.1
Web3.js v1.5.3
I´ll keep using the constructor as long as I didn´t understand the benefit of using the initializer with the upgradeable contracts.
Although, I´ll keep exploring the Contracts Wizard, looks very good.
Regards.
1 Like