Hi, I want to deploy erc721 contracts from my factory contract. But i am getting the following error in brownie-
ValueError: Execution reverted during call: 'execution reverted: ERC721: transfer to non ERC721Receiver implementer'. This transaction will likely revert. If you wish to broadcast, include
allow_revert:True as a transaction parameter.
My ERC721 contract:-
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract AdvancedCollectible is ERC721 {
uint256 public tokenCounter;
constructor(string memory collectionName, string memory symbol)
public
ERC721(collectionName, symbol)
{
tokenCounter = 0;
}
function createCollectible(string memory tokenUri)
public
returns (uint256)
{
uint256 newTokenId = tokenCounter;
_safeMint(msg.sender, newTokenId);
_setTokenURI(newTokenId, tokenUri);
tokenCounter += 1;
return tokenCounter;
}
}
My Factory or simple contract:-
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "./AdvancedCollectible.sol";
contract AdvancedCollectibleFactory {
AdvancedCollectible[] public collectibles;
function addCollection(
string memory collectionName,
string memory symbol,
string memory tokenUri
) public {
AdvancedCollectible collectible = new AdvancedCollectible(
collectionName,
symbol
);
collectible.createCollectible(tokenUri);
}
}
My brownie code for deploy:-
def deploy_and_create():
account=getAccount()
factory=AdvancedCollectibleFactory[-1]
#factory=AdvancedCollectibleFactory.deploy({'from':account})
print(factory.address)
txn=factory.addCollection('Birds','B',get_token_uri(),{'from':account, 'gas_limit': 9000000,})
txn.wait(1)
print('done')
address,token=factory.getCollectionData(0,{'from':account, 'gas_limit': 900000})
print(f'you can check your nft at {OPENSEA_URL.format(address,token-1)}')