Created
January 15, 2021 17:46
-
-
Save leonardoalt/bf22ba50585363e276395bb4b2d0553d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: GPL-v3 | |
pragma solidity ^0.8.0; | |
pragma experimental SMTChecker; | |
interface IERC777Recipient { | |
function tokensReceived( | |
address from, | |
address to, | |
uint256 amount | |
) external; | |
} | |
interface IERC777Sender { | |
function tokensToSend( | |
address from, | |
address to, | |
uint256 amount | |
) external; | |
} | |
contract ERC777 { | |
mapping (address => uint256) balances; | |
uint totalSupply; | |
bool lock; | |
function deposit(uint _amount) public payable { | |
require(_amount == msg.value); | |
require(msg.value > 0); | |
balances[msg.sender] += msg.value; | |
totalSupply += msg.value; | |
} | |
function withdraw(uint _amount) public { | |
require(_amount > 0 && _amount <= balances[msg.sender]); | |
payable(msg.sender).transfer(_amount); | |
balances[msg.sender] -= _amount; | |
totalSupply -= _amount; | |
} | |
function transfer(address _to, uint _amount) public { | |
require(msg.sender != _to); | |
require(_amount > 0); | |
require(balances[msg.sender] >= _amount); | |
uint preSupply = totalSupply; | |
balances[msg.sender] -= _amount; | |
balances[_to] += _amount; | |
//IERC777Sender(msg.sender).tokensToSend(msg.sender, _to, _amount); | |
//IERC777Recipient(_to).tokensReceived(msg.sender, _to, _amount); | |
assert(totalSupply == preSupply); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment