Guys i have 2 simple contracts but i'm not able to compile them, every time when i try i'm hitting this error Error in plugin hardhat-contract-sizer: Warning: 1 contracts exceed the size limit for mainnet deployment.
CollectionManager - used to instantiate multiple different Collections - 25.146kb
Collection - used to create NFT-s and payment splitter here is the source for both - 16.953kb
Collection Manager
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "../collection/Collection.sol";
import "./ICollectionManager.sol";
contract CollectionManager is ICollectionManager {
address[] private collections;
// Mapping from artist to collection addresses
mapping(address => address[]) private collectionsOf;
function createCollection(
string memory _uri,
string memory _name,
string memory _symbol,
uint256 _startingAt,
address[] memory _payees,
uint256[] memory _shares
) public {
Collection collection = new Collection(
_uri,
_name,
_symbol,
_startingAt,
_payees,
_shares
);
collections.push(address(collection));
collectionsOf[msg.sender].push(address(collection));
emit CollectionCreated(msg.sender, address(collection));
}
function create(
address payable _collectionAddress,
string calldata _cid,
uint256 _maxSupply
) external {
Collection(_collectionAddress).create(_cid, _maxSupply);
}
function mint(
address payable _collectionAddress,
address _account,
uint256 _id
) external {
Collection(_collectionAddress).mint(_account, _id);
}
function getCollections() external view returns (address[] memory) {
return collections;
}
function getCollectionForArtist(address _artist)
external
view
returns (address[] memory)
{
return collectionsOf[_artist];
}
}
- Collection
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
import "./ICollection.sol";
contract Collection is ICollection, ERC1155, Ownable, PaymentSplitter {
using Counters for Counters.Counter;
Counters.Counter private ID;
string public name;
string public symbol;
uint256 private startingAt;
// Mapping from token ID to token URI
mapping(uint256 => string) private idToUri;
// Mapping from token ID to max supply
mapping(uint256 => uint256) private maxSupply;
// Mapping from token ID to total supply
mapping(uint256 => uint256) private totalSupply;
constructor(
string memory _uri,
string memory _name,
string memory _symbol,
uint256 _startingAt,
address[] memory _payees,
uint256[] memory _shares
) payable ERC1155(_uri) PaymentSplitter(_payees, _shares) {
require(_startingAt > block.timestamp, "Invalid timestamp"); // + 5 * 86400 - 5 DAYS maybe/for example
name = _name;
symbol = _symbol;
startingAt = _startingAt;
}
function create(string calldata _cid, uint256 _maxSupply)
external
payable
override
onlyOwner
returns (uint256 _id)
{
require(startingAt > block.timestamp, "Already started");
require(_maxSupply > 0, "Supply > 0");
_id = _nextId();
maxSupply[_id] = _maxSupply;
totalSupply[_id] = 0;
string memory _uri = _createUri(_cid);
idToUri[_id] = _uri;
_mint(msg.sender, _id, 0, "");
emit Created(_uri, _id, msg.sender);
}
function mint(address _account, uint256 _id) external onlyOwner {
require(startingAt < block.timestamp, "Not started");
require(_exists(_id), "Invalid id");
require(totalSupply[_id] < maxSupply[_id], "Limit Reached");
totalSupply[_id] = totalSupply[_id] + 1;
_mint(_account, _id, 1, "");
}
function uri(uint256 _id) public view override returns (string memory) {
return idToUri[_id];
}
function _nextId() private returns (uint256 id) {
ID.increment();
return ID.current();
}
function _exists(uint256 _id) private view returns (bool) {
return (bytes(idToUri[_id]).length > 0);
}
function _createUri(string memory _cid)
private
view
returns (string memory _uri)
{
string memory baseUri = super.uri(0);
return string(abi.encodePacked(baseUri, _cid));
}
}
I have enabled:
settings: {
optimizer: {
enabled: true,
runs: 1,
},
},
but seems like not working properly or i'm receiving this error cuz my ManagerCollection contract is 25.146kb