ayalan / bloc

Minimal commandline build and deploy tool for the BlockApps API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bloc

BlockApps logo

Join the chat at https://gitter.im/blockapps/bloc Build Status

bloc is a small command line tool that helps you build blockchain applications on the Ethereum network with the blockapps api. Bloc makes it effortless to:

  • Compile and deploy smart contracts to the blockchain
  • Automatically wire those contracts to the front-end, so you can bring the blockchain to the world!

##Installation Installation is currently done by cloning:

git clone https://github.com/blockapps/bloc.git

Enter the bloc directory:

cd bloc

Install bloc as a global package:

npm install -g

##Generate a new blockchain app

You can use "bloc init" to create a sample app.

bloc init

bloc init

bloc init builds a base structure for your blockchain app as well as sets some default parameters values for creating transactions. These can be edited in the config.yaml file in your app directory.

The config.yaml file also holds the app's "apiURL". This can be configured to point to an isolated test network, or the real Ethereum network. You can change this link, which will allow you to build and test in a sandboxed environment, and later re-deploy on the real Ethereum blockchain.

You will find the following files in your newly created app directory:

/best_app_ever
  config.yaml
  /contracts
    Payout.sol
    SimpleStorage.sol
    SimpleMultiSig.sol
  /css
    styles.css
    bootstrap.min.css
  /html
  /js
  /meta
  /routes

An Ethereum app consists of three parts:

-The "contracts" directory holds Ethereum blockchain code, written in the Solidity language, which you can learn about here- https://ethereum.github.io/solidity/docs/home/. This is the code that will run on the blockchain. Samples contracts have been provided to get you started.

-The "html", "js", and "css" directories are intended to hold a frontend for your app. The "views" directory contains reusable templates that can be viewed from bloc's embedded webserver.

-Finally, we provide a REST API that will allow you to "glue" your frontend to the code you run in the blockchain. This API is described at https://strato1.blockapps.net/help.

##Creating a Sample Account

Now in your app directory run

bloc genkey

bloc genkey

This generates a new private key and fill it with test-ether (note- free sample Ether is only available on the test network, of course). You can view the address information in the newly created key.json file. Also, beware that this file contains your private key, so if you intend to use this address on the live network, make sure you keep this file hidden.

The new account has also been created on the blockchain, and you can view account information by using our REST API directly in a browser by visiting https://strato1.blockapps.net/eth/v1.0/account?address= < fill in your address here >

balance before

##Uploading Contracts

Getting a contract live on the blockchain is a two step process

  1. Compile the contract
  2. Upload the contract

To compile your smart contracts

bloc compile -s

bloc compile

If there are any bugs in your contract code, this is where you will be allowed to fix them.

Upload a contract and scaffold (-s) your dApp

bloc upload <ContractName> -s

bloc upload

Note that during these steps, javascript scaffolding code has been autogenerated in the "js" directory. You can use this to connect to your newly uploaded contract.

You will now see that Ether has been deducted from your account

balance after

Also, the newly created contract has been given its own address, which you can view in the data in the "meta" folder. Viewing contract information, including compiled bytecode for your Solidity contract can be done using the same URL that you use to view your own account information.

contract info

Commands

Usage: bloc <command> (options)

Commands:
  init               start a new project
  compile            compile contracts in contract folder
  upload [contract]  upload contract to blockchain
  genkey             generate a new private key and fill it at the faucet
  start              launch a webserver for your application
  send               start prompt, transfer (amount*unit) to (address)

Options:
  -s, --scaffold     scaffold html / js / css from your contracts when compiling or
                     uploading

Additional Resources

bloc uses blockapps-js, our simple library for interfacing with the blockchain. Smart contracts that are written in javascript-like language called Solidity. A good place to start playing around with Solidity is the online compiler.

About

Minimal commandline build and deploy tool for the BlockApps API


Languages

Language:JavaScript 72.4%Language:HTML 27.3%Language:CSS 0.3%