Skip to content

Instantly share code, notes, and snippets.

@elmariachi111
Last active April 8, 2022 17:42
Show Gist options
  • Save elmariachi111/4df402dcefa4a86c78545e5e0a44bc6b to your computer and use it in GitHub Desktop.
Save elmariachi111/4df402dcefa4a86c78545e5e0a44bc6b to your computer and use it in GitHub Desktop.
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