Back to Basic_smart contract 'Hello World'


Env preparation:

Node : v8.9.0

Npm: 5.5.1

mkdir smartcontract including two files package. jsonHello.sol

smartcontract

├── Hello.sol

└── package.json

Edit package.json

Back to Basic_smart contract 'Hello World'_第1张图片

fs module :  provides an API for interacting with the file system

solc module: solidity smart contract compiler

web3: package tool provided from Ethereum, used to communicate with smart contract.

Step 1 : smart contract writing

open Hello.sol

Back to Basic_smart contract 'Hello World'_第2张图片

Step 2: smart contract compile

open deploy.js

Back to Basic_smart contract 'Hello World'_第3张图片

ABI: Application Binary Interface. An interface between two binary program modules; often, one of these modules is a library or operating system facility, and the other is a program that is being run by a user.

Step 3: Smart Contract Deploy

$node deploy.js

compileCode

Back to Basic_smart contract 'Hello World'_第4张图片

Open a new terminal and run ganache-cil, you should see all the transactions logs here;

Back to Basic_smart contract 'Hello World'_第5张图片
图片发自App

Arrow points to contract address: 0xbf474d24ba8b19811db5deb51137ddccbe3ff288;

Step 4:Smart Contract invoke

Writing code to call function say() for testing. Build new file called run.js

Back to Basic_smart contract 'Hello World'_第6张图片

$node run.js

You should be able to see 'Hello world' in the terminal

In summary

One contract experiences four stages :  contract writing -> compile-> deploy-> call

你可能感兴趣的:(Back to Basic_smart contract 'Hello World')