Chapter 1. A first look at decentralized applications
Listing 1.1. First implementation of SimpleCoin, a basic cryptocurrency
Chapter 3. The Ethereum platform
Listing 3.1. SimpleCoin contract as you left it in chapter 1
Listing 3.2. A more robust transfer function with checks on the input
Listing 3.3. SimpleCoin with parameterized constructor, input validation, and event
Chapter 4. Deploying your first smart contract
Chapter 5. Programming smart contracts in Solidity
Listing 5.1. High-level contract structure
Listing 5.2. Reference types with location declared implicitly or explicitly
Listing 5.3. Contract containing various struct definitions
Listing 5.4. Examples of state variables declared with various accessibility levels
Listing 5.5. Functions you can declare as view or pure
Listing 5.6. Example of a contract with function modifiers
Listing 5.7. Latest version of SimpleCoin from chapter 4
Listing 5.8. Refactored version of SimpleCoin with extended functionality
Chapter 6. Writing more complex smart contracts
Listing 6.1. Core functionality a crowdsale contract provides
Listing 6.2. ReleasableSimpleCoin, with locked transfer() and transferFrom()
Listing 6.3. ReleasableSimpleCoin inherited from SimpleCoin
Listing 6.4. Ownable contract extracted from SimpleCrowdsale and SimpleCoin
Listing 6.5. Initial implementation of a crowdsale contract
Listing 6.6. calculateNumberOfTokens() based on tranche-based pricing
Listing 6.7. TranchePricingCrowdsale derived from SimpleCrowdsale
Listing 6.8. Adding pausable functionality to ReleasableSimpleCoin
Listing 6.9. Pausable contract extracted from ReleasableSimpleCoin
Chapter 7. Generalizing functionality with abstract contracts and interfaces
Listing 7.1. First implementation of CappedCrowdsale
Listing 7.2. Refactored CappedCrowdsale
Listing 7.3. Capped funding and tranche-based pricing
Listing 7.4. Crowdsale contracts combining different pricing and funding limit options
Listing 7.5. SimpleCrowdsale referencing ReleasableToken
Listing 7.6. SafeMath library for performing checked math operations
Listing 7.7. How to call library functions
Listing 7.8. How to call library functions from a contract
Listing 7.9. ERC20 abstract contract, defining the Ethereum standard token
Chapter 8. Managing smart contracts with Web3.js
Listing 8.1. SimpleCoin.sol, containing an early version of SimpleCoin
Listing 8.2. The geth interactive JavaScript instructions to deploy a contract
Listing 8.3. SimpleCoin Node.js deployment script
Listing 8.4. transferTokens.js script, which transfers coins between two accounts
Chapter 9. The Ethereum ecosystem
Listing 9.1. IPFS object associated with a file containing a single block
Listing 9.2. IPFS object of a file larger than 256 KB, split into various blocks
Listing 9.3. Contract providing ETHXBT rate from the Kraken exchange through Oraclize
Chapter 10. Unit testing contracts with Mocha
Chapter 11. Improving the development cycle with Truffle
Listing 11.1. contracts/Migrations.sol
Listing 11.2. 2_deploy_contracts.js: SimpleCoin's migration script
Listing 11.3. 1_initial_migration.js: Migrations’ migration script
Listing 11.4. truffle.js (or truffle-config.js): Truffle pointing to Test Develop
Listing 11.5. TestSimpleCoin.sol test contract
Listing 11.6. Original Mocha test on the constructor, verifying contract ownership
Listing 11.7. Truffle constructor test verifying contract ownership
Chapter 12. Putting it all together: Building a complete voting Dapp
Listing 12.1. 2_deploy_contracts.js: migration configuration for SimpleVoting
Listing 12.2. testSimpleVoting.js: testing ending the proposal registration session
Chapter 14. Security considerations
Listing 14.1. Example of execution in the context of an external contract
Listing 14.2. Example of delegatecall execution in the context of a calling contract
Listing 14.3. Incorrect implementation of an Auction contract
Listing 14.4. A malicious contract calling the Auction contract
Listing 14.5. Correct implementation of an Auction contract
Listing 14.6. Incorrect implementation of a function making several payments
Appendix A. SimpleCoin inherited from Ownable
Listing A.1. Refactored SimpleCoin contract, inherited from Ownable
Appendix B. Full SimpleCrowdsale application
Listing B.1. Full SimpleCrowdsale application, including crowdsale and coin contracts
Appendix C. SimpleCoin Mocha unit testing suite
Appendix D. impleVoting contract