Closed Martin-Fritsche closed 2 years ago
I think I needed to add payable to the function header of each function. I assumed the mutability would be inherited (IERC721A sets the mutability of these functions to payable), but I needed to be added to the function header explicitly.
It should have been
function transferFrom(address from, address to, uint256 tokenId) public payable override(ERC721A, IERC721A) onlyAllowedOperator(from) { super.transferFrom(from, to, tokenId); }
function safeTransferFrom(address from, address to, uint256 tokenId) public payable override(ERC721A, IERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId); }
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public payable override(ERC721A, IERC721A) onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId, data); }
I'm working on trying to enforce royalties for a smart contract. I just read that OpenSea came out with a contract extension that excludes marketplaces that don't enforce royalties.
I'm currently implementing this extension into a smart contract. However, I am getting an error that I can't resolve.
The contract inherits from ERC721A.
THIS IS THE ERROR
TypeError: Overriding function changes state mutability from "payable" to "nonpayable". --> contracts/MyNFTContractTest.sol:66:5: | 66 | function transferFrom(address from, address to, uint256 tokenId) public override(ERC721A, IERC721A) onlyAllowedOperator(from) { | ^ (Relevant source part starts here and spans across multiple lines). Note: Overridden function is here: --> erc721a/contracts/ERC721A.sol:540:5:
THIS IS THE ERROR
THIS IS THE CONTRACT -- edited for space
// SPDX-License-Identifier: MIT pragma solidity >=0.8.4 <0.9.0;
import "erc721a/contracts/ERC721A.sol"; import "erc721a/contracts/extensions/ERC721AQueryable.sol"; import "erc721a/contracts/extensions/ERC721ABurnable.sol"; import "erc721a/contracts/extensions/ERC4907A.sol"; import "./DefaultOperatorFilterer721.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
contract MyNFTContractTest is ERC2981, ERC721A, ERC721AQueryable, ERC721ABurnable, ERC4907A, Ownable, DefaultOperatorFilterer721{
*THESE FUNCTIONS CAUSE THE ERROR***
*THESE FUNCTIONS CAUSE THE ERROR***
}
THIS IS THE CONTRACT -- edited for space