Git Product home page Git Product logo

blockchainintensive2017's Introduction

BlockchainIntensive2017

Hi all this repository for support Microsoft Blockchain Intense 2017

Nedeed instruments

Truffle framework http://truffleframework.com/ https://truffle-box.github.io/ TestRPC https://github.com/ethereumjs/testrpc Geth - https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu

How to set-up Dev Environment

Windows Subsytem for Linux intallation:

  1. Turn-om Windows subsystem for Linux in "Turn Windows Features on or off" More info - https://msdn.microsoft.com/en-us/commandline/wsl/install_guide

  2. Start Ubuntu Bash from searching bar

  3. Takes a clean Ubuntu image, up to being dev ready. install npm from official repo, as apt-get has a very old version of npm:

    curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -

    sudo apt-get update -y && sudo apt-get upgrade -y

  4. Install the NodeJs

    sudo apt-get install -y build-essential python nodejs

  5. Upgrade npm before install tools

    sudo npm install -g npm

    sudo npm install -g ethereumjs-testrpc truffle

    if you have access error, try to use

    unsafe parameters - sudo npm install --unsafe-perm --verbose -g ethereumjs-testrpc

  6. Intall geth

    sudo apt-get install software-properties-common

    sudo add-apt-repository -y ppa:ethereum/ethereum

    sudo apt-get update

    sudo apt-get install ethereum

Linux installation

The same as for Windows subsytem

Test Guide

  1. How to use truffle console
Truffle v3.2.5 - a development framework for Ethereum
Usage: truffle <command> [options]
Commands:
  init      Initialize new Ethereum project with example contracts and tests
  compile   Compile contract source files
  migrate   Run migrations to deploy contracts
  deploy    (alias for migrate)
  build     Execute build pipeline (if configuration present)
  test      Run Mocha and Solidity tests
  console   Run a console with contract abstractions and commands available
  create    Helper to create new contracts, migrations and tests
  install   Install a package from the Ethereum Package Registry
  publish   Publish a package to the Ethereum Package Registry
  networks  Show addresses for deployed contracts on each network
  watch     Watch filesystem for changes and rebuild the project automatically
  serve     Serve the build directory on localhost and watch for changes
  exec      Execute a JS module within this Truffle environment
  version   Show version number and exit

See more at http://truffleframework.com/docs
  1. For BASIC Truffle project
truffle init
truffle console

-How to get accounts

web3.eth.accounts

2.1. How to get reference to deployed contract

var metaCoin;
MetaCoin.deployed().then(function(deployed) {metaCoin = deployed;});

2.2. How to get balance of account 0

metaCoin.getBalance.call(web3.eth.accounts[0])

2.3. How to send coins

var account1 = web3.eth.accounts[1];
metaCoin.sendCoin(account1, 1000, {from: account0});
metaCoin.getBalance.call(account0);

How to deploy Smart Contract to Ethereum BaaS on Azure by using truffle

  1. Go to folder with truffle project
  2. Add parameters of Deployed Azure template to truffle.js:
    module.exports = {
  networks: {
  azure :{
      host: "", //Adress of your Azure RPC endpoints (Deployments - Output)
      port: 8545, //Port of RPC - basically rest the same
      network_id: "" //Network id which you have choose when created the network 
    },
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    }
  }
};
  1. Safe file
  2. Try to migrate your Smart contact by using truffle migrate --network azure
You will get the following error:
Running migration: 1_initial_migration.js
  Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: account is locked 
For resolve this problemm you need to unlock the account
  1. Connect to your TX node (Deployments - Output - SSH to first Tx node)
  2. Run geth attach command
  3. Run personal.unlockAccount(eth.coinbase) command to unlock the account
  4. Migrate your smart contract truffle migrate --network azure
  5. To connect to truffle console type truffle console --network azure

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.