Skip to main content

In this tutorial we continue following Alice in her attempts to monetise her blog posts. Alice has realised that she needs some help with her writing and decides to enlist Edward the editor. Ed has agreed to accept 20% of each contribution Alice receives.

In an earlier tutorial, Alice created a wallet and a very basic app which allowed her readers to transfer Ether via an embedded button, however this will no longer suffice since incoming funds need to be forwarded to multiple accounts. Alice thus endeavours to build a Smart Contract.

Before deploying an actual contract on the Ethereum blockchain, she decides to experiment - aware that mistakes now, may cause problems later.

She chooses to use TestRPC and Truffle which you can install with

npm install -g ethereumjs-testrpc

npm install -g truffle


Ethereum TestRPC is a fast and flexible way to emulate calls to the blockchain without the overheads of running an actual Ethereum node. Features include:

  • Accounts can be re-used and reset.
  • The live blockchain can be forked at a given block to test existing in-the-wild contracts.
  • Specific accounts can be instantiated with a fixed amount of Ether (no need for faucets or mining).
  • Gas price and mining speed can be modifed.

To launch TestRPC run:

testrpc -m "warrior minimum breeze raven garden express solar flavor obvious twenty alpha actress"

This will create a running instance of TestRPC with accounts generated from the "brain wallet" passed in with the -m switch. 

TestRPC console output



Truffle is a framework for rapid development, testing and deployment of smart contracts with Solidity and Javascript. Solidity is a JS-like high level contract language that compiles down to bytecode used in the EVM (Ethereum Virtual Machine).

Running truffle init will create an example project with folder structure

├── build/
├── contracts/
├── migrations/
└── test/
  • build contains the compiled version of contracts after running truffle compile
  • contracts is where we will build our Solidity based contracts
  • migrations helps us manage migration of contracts as we make changes over the contracts lifetime
  • test contains Mocha based tests


Alice's contract code (truffle create contract AuthorDonationExampleadds AuthorDonationExample.js file in /contracts directory)

Alice's test code ( truffle create test adds AuthorDonationsTestadds AuthorDonationsTest.js file to /test drectory)


After writing this draft of her contract Alice realises there are a few problems that need resolved.  The contract will live forever (at least until Serenity is released) and she cannot amend or update it. In her next revision, she will deal with this problem and abstract her solution a little further to create a generic payment button combined with a dynamic smart contract.


Part 1 | Part 2 | Part 3 | Part 4 | Part 5

For more information on this topic, to ask questions, or to find out how we might be able to help you.

Please feel free to email:



Want to join our team?

Copyright © City Web Consultants Ltd. 2017. All Rights Reserved
Company number: 27234161

Want to start something?

Fantastic! We'd love to hear from you, whethere it's a pitch, an idea or just saying hello!

Feel free to get in touch.


Drop us an email?


Or give us a call?

+44 (0) 191 691 1296


Playing hard to get? We'll contact you