diff options
author | Nemil Dalal <nemild@gmail.com> | 2015-11-23 16:39:05 -0500 |
---|---|---|
committer | Nemil Dalal <nemild@gmail.com> | 2015-11-23 16:39:05 -0500 |
commit | 08f3ee3687fc18286fdb3825f0fc1fd74c086798 (patch) | |
tree | 32628d69be80ec131be4692c38db7001e10b299f /solidity.html.markdown | |
parent | d5bcbceb21954d0f8739fb841fc511aa32c2bcc6 (diff) |
Added remove function
Diffstat (limited to 'solidity.html.markdown')
-rw-r--r-- | solidity.html.markdown | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/solidity.html.markdown b/solidity.html.markdown index 79debed6..bcbdec5f 100644 --- a/solidity.html.markdown +++ b/solidity.html.markdown @@ -35,15 +35,13 @@ contract AcmeBank { function AcmeBank() { // msg is a default variable that provides both the // contract messager's address and amount - owner = msg.address; - // the owner has no additional rights, we're setting it for - // illustrative purposes + owner = msg.address; // msg.address refers to the address of the contract creator } function deposit(uint balance) { balances[msg.sender] += msg.value; // no need for "this." or "self." in front of the state variable - return balances[msg.sender]; + return balances[msg.sender]; // msg.sender refers to the contract caller } function withdraw(uint withdrawAmount) returns (uint remainingBalance) { @@ -58,6 +56,13 @@ contract AcmeBank { } } + // It's good practice to have a remove function, which disables this contract + function remove () { + if(msg.sender == owner) { // Only let the contract creator do this + suicide(owner); // suicide makes this contract inactive, and returns funds to the owner + } + } + // The 'constant' prevents the function from editing state variables function balance() constant { return balances[msg.sender]; |