I'm trying to deploy a smart contract and get this error each time
Warning! Error encountered during contract execution [contract creation code storage out of gas]
pragma solidity ^0.8.4;
// it has trouble with workspace
import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "../node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol";
import "../node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "../node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "../node_modules/@openzeppelin/contracts/security/Pausable.sol";
import "../node_modules/@openzeppelin/contracts/access/AccessControl.sol";
import "../node_modules/@openzeppelin/contracts/utils/Counters.sol";
import "../node_modules/@openzeppelin/contracts/access/Ownable.sol";
contract BaseCollection is ERC721, ERC721Enumerable, ERC721URIStorage, ERC721Royalty, Ownable, Pausable, AccessControl {
using Counters for Counters.Counter;
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
Counters.Counter private _tokenIdCounter;
constructor(
string memory name,
string memory symbol
) ERC721(name, symbol) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
_grantRole(MINTER_ROLE, msg.sender);
}
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}
function unpause() public onlyRole(PAUSER_ROLE) {
_unpause();
}
function safeMint(address to, string memory uri) public onlyRole(MINTER_ROLE) {
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal
whenNotPaused
override(ERC721, ERC721Enumerable)
{
super._beforeTokenTransfer(from, to, tokenId);
}
// The following functions are overrides required by Solidity.
function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage, ERC721Royalty) {
super._burn(tokenId);
}
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, AccessControl, ERC721Royalty)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
Then I generated abi and bin with
solc --optimize --abi ./contracts/contract.sol -o ./abi/collection --overwrite
solc --optimize --bin ./contracts/contract.sol -o ./bin
I generate my Go library with
abigen --bin=./smart-contracts/bin/BaseCollection.bin --abi=./smart-contracts/abi/collection/BaseCollection.abi --pkg=contract_collection --out=./core/repositories/contracts/collection/collection.go --type Collection
I try to deploy it this way
auth, err := bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(5))
if err != nil {
log.Fatal(err)
}
auth.Nonce = big.NewInt(int64(nonce))
auth.Value = big.NewInt(0) // in wei
auth.GasLimit = uint64(1000000) // in units
auth.GasPrice = gasPrice
address, tx, instance, err := contract_collection.DeployCollection(auth, client, "test", "yes")
But each time I run this function I get this error, here is the etherscan of my wallet https://goerli.etherscan.io/address/0x7a7da62d3e43beb63c30a341362039cddf71babd
Does anyone have any idea what is going on?