Skip to content

Instantly share code, notes, and snippets.

Created September 11, 2017 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/77b240dcbac0a769a510ab091554e20e to your computer and use it in GitHub Desktop.
Save anonymous/77b240dcbac0a769a510ab091554e20e to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.16+commit.d7661dd9.js&optimize=undefined&gist=
pragma solidity ^0.4.0;
contract Sample {
mapping(address => address) arr;
uint8 limit;
function Sample(uint8 _limit) {
limit = _limit;
}
//i am the sender. if my balance > limit this receiver can take my 1 ether
function Accept(address _receiver){
arr[msg.sender] = _receiver;
}
//i am the receiver and the sender gave me 1 ether. i wants to receive it.
function Take(address sender){
if(msg.sender != arr[sender])
return;
if(sender.balance < limit)
return;
//how can contract send 1 ether from sender to receiver(msg.sender)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment