Another example

An example of a simple contract is shown in the section. This is a simple contract in solidity, which performs only addition. We will see how migrations and tests can be created for this contract.

Follow the steps outline:

  1. Create a directory named simplecontract:
    $ mkdir simplecontract  
  1. Change directory to simplecontract:
    $ cd simplecontract  
  1. Initialize Truffle to create a skeleton structure for smart contract development:
$ truffle init truffle init 
Downloading... 
Unpacking... 
Setting up... 
Unbox successful. Sweet! 
 
Commands: 
 
  Compile:        truffle compile 
  Migrate:        truffle migrate 
  Test contracts: truffle test 

The tree structure produced by the init command is as follows:

      ├── contracts
      │   └── Migrations.sol
      ├── migrations ...

Get Mastering Blockchain - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.