Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. pragma solidity ^0.4.22;
  2.  
  3. contract BasicToken {
  4. uint public initialSupply;
  5.  
  6. mapping(address=>uint) balances;
  7.  
  8. constructor(uint _initialSupply) public {
  9. initialSupply = _initialSupply;
  10. balances[msg.sender] = _initialSupply;
  11. }
  12.  
  13. function transfer(address _recipient, uint _amount) public {
  14. require(balances[msg.sender] >= _amount, "Not enough funds");
  15. require(_recipient != msg.sender, "No need to send tokens to yourself");
  16. require(balances[_recipient] + _amount > balances[_recipient]); //overflow check
  17. balances[msg.sender] -= _amount;
  18. balances[_recipient] += _amount;
  19. }
  20.  
  21. function balanceOf(address _owner) public view returns (uint) {
  22. return balances[_owner];
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement