Add exposition around example bank

This commit is contained in:
Nemil Dalal 2015-11-30 16:51:53 -05:00
parent 8ef890b0de
commit add8f68f1a

View File

@ -13,6 +13,10 @@ As Solidity and Ethereum are under active development, experimental or beta feat
```javascript
// Let's start with a simple Bank contract, before diving into to the key components of the language
// This bank has three main capabilities:
// - deposit
// - withdrawal
// - check balance
// ** START EXAMPLE **
// Start with a Natspec comment (the three slashes) that can be used
@ -57,14 +61,6 @@ contract AcmeBank {
}
}
// It's good practice to have a remove function, which disables this
// contract - but does mean that users have to trust the owner
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];
@ -406,6 +402,14 @@ function remove() {
// - crowdfunding?
// - Peer to peer insurance
// ]
// It's good practice to have a remove function, which disables this
// contract - but does mean that users have to trust the owner
// For a decentralized bank without a trusted part
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
}
}
// *** END EXAMPLE ***