ynifor

Untitled

Nov 28th, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. pragma solidity >=0.4.22 <0.6;
  2.  
  3. contract WJUNE {
  4. string public name = "Wrapped JUNE";
  5. string public symbol = "wJUNE";
  6. uint8 public decimals = 18;
  7.  
  8. event Approval(address indexed src, address indexed guy, uint wad);
  9. event Transfer(address indexed src, address indexed dst, uint wad);
  10. event Deposit(address indexed dst, uint wad);
  11. event Withdrawal(address indexed src, uint wad);
  12.  
  13. mapping (address => uint) public balanceOf;
  14. mapping (address => mapping (address => uint)) public allowance;
  15.  
  16. function() external payable {
  17. deposit();
  18. }
  19. function deposit() public payable {
  20. balanceOf[msg.sender] += msg.value;
  21. emit Deposit(msg.sender, msg.value);
  22. }
  23. function withdraw(uint wad) public {
  24. require(balanceOf[msg.sender] >= wad);
  25. balanceOf[msg.sender] -= wad;
  26. msg.sender.transfer(wad);
  27. emit Withdrawal(msg.sender, wad);
  28. }
  29.  
  30. function totalSupply() public view returns (uint) {
  31. return address(this).balance;
  32. }
  33.  
  34. function approve(address guy, uint wad) public returns (bool) {
  35. allowance[msg.sender][guy] = wad;
  36. emit Approval(msg.sender, guy, wad);
  37. return true;
  38. }
  39.  
  40. function transfer(address dst, uint wad) public returns (bool) {
  41. return transferFrom(msg.sender, dst, wad);
  42. }
  43.  
  44. function transferFrom(address src, address dst, uint wad)
  45. public
  46. returns (bool)
  47. {
  48. require(balanceOf[src] >= wad);
  49.  
  50. if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
  51. require(allowance[src][msg.sender] >= wad);
  52. allowance[src][msg.sender] -= wad;
  53. }
  54.  
  55. balanceOf[src] -= wad;
  56. balanceOf[dst] += wad;
  57.  
  58. emit Transfer(src, dst, wad);
  59.  
  60. return true;
  61. }
  62. }
Add Comment
Please, Sign In to add comment