contract P_Bank{ mapping (address => uint) public balances; uint public MinDeposit = 0.1 ether; Log TransferLog;
event FLAG(string b64email, string slogan);
constructor(address _log) public { TransferLog = Log(_log); }
function Ap() public { if(balances[msg.sender] == 0) { balances[msg.sender]+=1 ether; } }
function Transfer(address to, uint val) public { if(val > balances[msg.sender]) { revert(); } balances[to]+=val; balances[msg.sender]-=val; }
function CaptureTheFlag(string b64email) public returns(bool){ require (balances[msg.sender] > 500 ether); emit FLAG(b64email, "Congratulations to capture the flag!"); }
function Deposit() public payable { if(msg.value > MinDeposit) { balances[msg.sender]+= msg.value; TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); } }
The person who does not have money in P_Bank can call AP() to get 1 ETH. But the contract doesn’t record who has called it! It means that I can call AP() and get money, transfer it to others, get money ,transfer…….it is convenience for a contract to do it .
By the way, even if the contract records the users who have called AP(), we can still create many accounts to operate. Creating accounts in Ethereum is an easy task. This is called “撸空投” in Chinese.