From d1bd3d187dfe238e1991ae2e62ddb2cefff75900 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Tue, 26 Nov 2024 14:53:59 +0700 Subject: [PATCH] Create royalty_contract.py --- .../src/smart_contracts/royalty_contract.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 QuantumNexusProtocol/src/smart_contracts/royalty_contract.py diff --git a/QuantumNexusProtocol/src/smart_contracts/royalty_contract.py b/QuantumNexusProtocol/src/smart_contracts/royalty_contract.py new file mode 100644 index 000000000..800ff304b --- /dev/null +++ b/QuantumNexusProtocol/src/smart_contracts/royalty_contract.py @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract RoyaltyContract { + mapping(address => uint256) public royalties; + + event RoyaltyPaid(address indexed creator, uint256 amount); + + function payRoyalty(address creator) external payable { + require(msg.value > 0, "Royalty amount must be greater than zero"); + royalties[creator] += msg.value; + emit RoyaltyPaid(creator, msg.value); + } + + function withdrawRoyalties() external { + uint256 amount = royalties[msg.sender]; + require(amount > 0, "No royalties to withdraw"); + royalties[msg.sender] = 0; + payable(msg.sender).transfer(amount); + } +}