current position:Home>Ethereum series - DAPP development three swordsman

Ethereum series - DAPP development three swordsman

2022-02-03 05:29:48 Brick moving leader

Build the Ethereum private chain , Three common tools for deploying smart contracts :Truffle,Ganache and remix-ide.

Truffle

Truffle Is the most popular development framework , Able to compile locally 、 Deploy smart contracts , The mission is to make development easier .

Truffle Source code address of
  https://github.com/trufflesuite/truffle

(1) install Truffle 4.0
   Depend on the environment :

  • NodeJS 5.0+
  • Windows,Linux, or Mac OS X

Easy to install :

npm install -g truffle

# View the installed version :
truffle version

(2) Initialize a Truffle project

truffle init 			# You can initialize a default Ethereum Token Contract items 

Compile contract

truffle compile			# Only files that have been modified since the last compilation are compiled by default 
truffle compile --all	# Compile all files 

Truffle The contract name and file name that need to be defined match exactly , This match is case sensitive , In other words, the case should be the same . It is recommended to capitalize every initial letter

(3) Deploy
Default network [development]

truffle migrate
truffle migrate --reset		# Re execution 

Appoint network

truffle migrate --network poa

(4) Launch the console ( It needs to be executed under the project directory .)

# Use the default network to set up a console 
truffle console
# Appoint network
truffle console --network poa
# Start the console with local private development chain 
truffle develop
# The monitoring address is : http://127.0.0.1:9545

Test the smart contract successfully deployed

# Enter the following command to open truffle Console , Test what we just deployed Hello_mshk_top contract :

truffle(development)> var contract;
undefined
truffle(development)> Hello_mshk_top.deployed().then(function(instance){
    contract= instance;}); // take Hello_mshk_top Contract subject , Pass to contract Variable 
undefined
truffle(development)> contract.say()
'Hello mshk.top'
truffle(development)> contract.print("https://mshk.top")
'https://mshk.top'

(5) Use zeppelin-solidity library

npm install zeppelin-solidity

# Generate package.json file 
npm init
# according to package.json Auto download library 
npm install

(6) Download the template

truffle unbox <box-name>

Ganache

TaiFang client during development Ganache ,ganache-cli

Deploy smart contracts to TestRPC( Blockchain in memory ) Medium test (TestRPC It has been renamed ganache)
It is a complete blockchain in memory, which only exists on the device you develop .
be relative to Geth,TestRPC It returns in real time when executing a transaction , Instead of waiting for the default block out time , So you can quickly verify your newly written code , When an error occurs , It can also give you immediate feedback .
It is also a powerful client that supports automated testing

(1)Ganache ( belt ui)
download
https://truffleframework.org/ganache/
The monitoring address is : http://127.0.0.1:7545

(1)ganache-cli

# install 
npm install -g ganache-cli
# function 
ganache-cli --gasLimit 0x800000000
# The monitoring address is  127.0.0.1:8545

(2)TestRPC (TestRPC It has been renamed ganache)

# install  
npm install -g ethereumjs-testrpc
# start-up  TestRPC
testrpc --gasLimit 0x800000000
 The monitoring address is  localhost:8545

remix-ide

install remix-ide

windows

# Install first node.js
https://nodejs.org/en/
# Again 
npm install remix-ide -g --allow-root
# function  cd Go to the development contract Directory 
remix-ide

linux

npm install remix-ide -g --allow-root
remix-ide
# If you can't access the Internet 
vim /root/remix-ide/bin/remix-ide 
# modify 
server.listen(8080, ‘127.0.0.1’, function () {
    }) 
# by 
server.listen(8080, ‘0.0.0.0’, function () {
    })

Past highlights :
Blockchain Knowledge Series
Cryptography series
Zero knowledge proof series
Consensus series
Public chain research series
Bitcoin series
Ethereum series
EOS series
Alliance chain series
Fabric series
Smart contract series
Token series

copyright notice
author[Brick moving leader],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202030529463776.html

Random recommended