Advertisement
Guest User

royalty example solidity

a guest
May 13th, 2022
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. pragma solidity ^0.8.0;
  2. contract royaltyExample {
  3. uint8 royalty = 50; //this is 50%
  4. address payable owner;
  5.  
  6. constructor() {
  7. owner = payable(msg.sender);
  8. }
  9.  
  10. function sendMoneySomewhere(address payable _to) public payable {
  11. uint256 amount = (msg.value * royalty) / 100;
  12. _to.transfer(amount);
  13. }
  14.  
  15. function withdrawAll() public {
  16. require(msg.sender == owner);
  17. payable(msg.sender).transfer(address(this).balance);
  18. }
  19.  
  20. function withdrawAmount(uint256 _amount) public {
  21. require(msg.sender == owner);
  22. payable(msg.sender).transfer(_amount);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement