Overview
The fold tree is like following:
1 | --| contracts |
Code
Smart Contract
1 | pragma solidity ^0.4.17; |
Compile Script
1 | const path = require('path'); |
run node compile
:
1 | { contracts: |
Test case
1 | const assert = require('assert'); |
then run npm run text
:
1 | > inbox@ test /Users/mac/Code/blockchain |
Deploy to ethereum
Infura API
: provide the interface of real ethereum block chain.Provider
: a interface layer to communicate with real block chain using your account.
Get infura api
Go to infura.io to creata a new account and project.
Deploy
1 | const HDWalletProvider = require('truffle-hdwallet-provider'); |
1 | mac@HansonMac ~/Code/blockchain node deploy.js |
copy 0xF0f127B8eC22da8e811262B287BA6b8244B22891
to rinkey.etherscan.io
to see the results.
Interact with real ethereum
Go to remix website
copy 0xF0f127B8eC22da8e811262B287BA6b8244B22891
to At Address
, and click.
You will see the contract deployed in real ethereum network.
You can then try to setMessage, for example: ‘Test real ethereum’.
After your submition, the transaction will be in pending
state.
While in the pending state, the value of message will not change. After the transaction is confirmed, message
function will return the new value: ‘Test real ethereum’.