Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OneOnOneNFT.sol
// contracts/Splice.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import '@openzeppelin/contracts/utils/math/SafeMath.sol';
contract OneOnOneNFTMarketPlace {
using SafeMath for uint256;
struct RoyaltyReceiver {
address creator;
uint8 royaltyPercent;
}
mapping(uint256 => RoyaltyReceiver) royalties;
function mint(
/*...mint args...*/
uint8 _royaltyPercent
) public {
//... minting logic ...
uint256 token_id = 1;
royalties[token_id] = RoyaltyReceiver({
creator: msg.sender,
royaltyPercent: _royaltyPercent
});
}
function royaltyInfo(uint256 tokenId, uint256 salePrice)
public
view
returns (address receiver, uint256 royaltyAmount)
{
receiver = royalties[tokenId].creator;
royaltyAmount = (royalties[tokenId].royaltyPercent * salePrice).div(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment