I'm looking to integrate these two things together into one contract for a basic 1/1 NFT. How exactly is this written together? Note they are two different compilers and they both need to be the same I think. I'm working within remix IDE if it helps to know.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;
import "https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol";
import "https://github.com/0xcert/ethereum-erc721/src/contracts/ownership/ownable.sol";
contract newNFT is NFTokenMetadata, Ownable {
constructor() {
nftName = "Synth NFT";
nftSymbol = "SYN";
}
function mint(address _to, uint256 _tokenId, string calldata _uri) external onlyOwner {
super._mint(_to, _tokenId);
super._setTokenUri(_tokenId, _uri);
}
}
and
pragma solidity ^0.6.0;
interface IERC2981 {
/// @notice Called with the sale price to determine how much royalty
// is owed and to whom.
/// @param _tokenId - the NFT asset queried for royalty information
/// @param _salePrice - the sale price of the NFT asset specified by _tokenId
/// @return receiver - address of who should be sent the royalty payment
/// @return royaltyAmount - the royalty payment amount for _salePrice
function royaltyInfo(
uint256 _tokenId,
uint256 _salePrice
) external view returns (
address receiver,
uint256 royaltyAmount
);
}
https://medium.com/geekculture/mint-an-nft-and-erc-721-smart-contract-easy-step-by-step-4fafff151fbe
https://medium.com/knownorigin/eip-2981-simple-and-effective-royalty-standards-for-all-dbd0b761a0f0
Best Answer
check out https://www.gemini.com/blog/exploring-the-nft-royalty-standard-eip-2981 for an article. They are using the openzepplin contracts vs. 0xcert
the solidity code is on https://github.com/dievardump/EIP2981-implementation
This is rough but I threw it together and did a couple transactions in Remix and it seemed to work - I'm still a beginner with this so if you see any big problems please let me know...:
The mock contract:
ERC2981PerTokenRoyalties.sol contract:
IERC2981Royalties contract:
The above is using 0xcert base contracts... I just saw this code that leverages openzepplin --it looks very well written.