current position：Home>Ethereum smart contract - building the basic environment
Ethereum smart contract - building the basic environment
2022-02-03 15:41:02 【xiyan0033】
truffle It is the development tool of Ethereum smart contract ,
truffle The basic environment is
nodejs, Therefore, we need to download and install... On the system first
Execute the following command , If it can output normally , It can be determined that
nodejs Installed successfully .
In the installation
nodejs Will be installed at the same time
nodejs Package manager in the world , Manages the
nodejs Most open source packages in the world . for example , When we execute the following command , Can install
npm install -g truffle
By default ,
npm You need to download packages from foreign servers , The speed is often very slow . therefore , I suggest the following instructions , take
npm The image server is configured as alicloud to improve the download speed of packages .
npm config set registry https://registry.npm.taobao.org --global
When we configure the image resources , We can query whether the configuration is successful through the following command .
npm config get registry
Now let's officially execute the installation command to install
npm install -g truffle
If you encounter the following problems during installation , Indicates that the current system is not installed
python Or no configuration
python The environmental path of .
You can download it through the official website python,https://www.python.org/downloads/, Because the official website is relatively slow , Recommend a download link in Huawei image ,https://mirrors.huaweicloud.com/python/, According to the current time , Download the latest or next version , The version I downloaded is
During installation , Note that the check box will Python Add the execution path to the environment variable , As shown in the figure below .
After installation , You can judge by the following command python Has it been installed successfully ：
python --version # Python 3.10.0a2
npm install truffle -g To install
truffle, And judge whether the whole installation is successful through the following command .
truffle version # Truffle v5.4.22 (core: 5.4.22) # Solidity v0.5.16 (solc-js) # Node v10.24.1 # Web3.js v1.5.3
Use these three commands to initialize the project , The first two create an empty folder , The latter one initializes
truffle project .
$ mkdir metacoin $ cd metacoin $ truffle init Starting init... ================ > Copying project files to D:\Program Files\metacoin Init successful, sweet! Try our scaffold commands to get started: $ truffle create contract YourContractName # scaffold a contract $ truffle create test YourTestName # scaffold a test http://trufflesuite.com/docs
After project initialization , We can see the directory shown in the figure below ：
below , We create a contract and test it
$ truffle create contract Metacoin $ truffle create contract MetacoinTest
here , Let's look at the directory structure , Two new files ,
Metaconin.sol It means the contract document 、
metacoin_test.js It represents the test file of the contract ：
Ganache Used to simulate Ethereum network , Run locally , Locally developed smart contracts can be run directly locally Ganache In the simulated Ethereum network , It is convenient for programmers to debug smart contracts .
We log on to the website ：http://trufflesuite.com/ganache/, Download a Windows Version Simulator .
Install and run the simulator , A virtual Ethereum network will be created immediately after normal startup , And randomly create 10 A virtual Ethereum account .
There are several points to pay attention to ：
The network created by the simulator and the listening port are
The Internet ID by
Each line in the list displays ： Account address , The account balance , Number of transactions in the account , Account index and the most important account private key , That is, the small key displayed in the last column of each row , Click the small key to see the private key of each account .
The content mentioned above , Will be used later , At that time, we will have a deeper understanding of these contents , It doesn't matter if you don't know now .
You can download it through the official website VScode,https://code.visualstudio.com/, The software is a general code editor developed by Microsoft , The installation is relatively simple , There is no more meaningful description here .
If you simply use native
VScode, You will find that this editor is the official language of Ethereum smart contract
Solidity Not enough support , And all buttons are in English , Inconvenient for us to use . therefore , We're going to give the original
VScode Install some plug-ins to solve the problems mentioned above .
In the open interface , Click the application extension button as shown in the figure .
The following figure shows some plug-ins I installed , Readers can install... According to their preferences , Be careful , Marked red
solidity Plug in must be installed .
such , Through the above three steps , We have built the development environment of Ethereum , Now we will enter the formal development of Ethereum .
author[xiyan0033],Please bring the original link to reprint, thank you.
The sidebar is recommended
- Bloomberg 2022 encryption Outlook: the United States may accept cryptocurrency next year
- Curtis sword (CSC), the first 3D chain game of the concept of meta universe, will be launched soon
- Defi Criticism: in addition to more speculation, it is also an amplifier of greed and fear
- 5g private network + blockchain: building the "cornerstone of security and trust" of smart government
- US media: another huge theft of cryptocurrency was exposed, and hackers stole nearly $200 million
- The chief economist of the International Monetary Fund stressed the "global policy demand" of crypto regulation
- Is NFT music an untapped opportunity?
- The 2nd edition of 1 inch price limit order agreement was officially released
- Decentralized Oracle adameral blockchain data interaction Middleware
- Coinbase releases the vision of metauniverse, or will become Facebook of the early Internet
guess what you like
Aofex exchange was investigated by the police, and the cryptocurrency exchange retreated into the countdown
Blockchain talent shortage, world chain job effectively improves the matching rate of people and posts
DAPP Industry Report in 2021: daily living addresses exceeded 2.7 million, and NFT trading volume exceeded US $23 billion
Happy bitcoin bear market day: three years have passed since BTC bottomed at $3100
Teach you how to use Nansen to play NFT
Win10 uses geth client to build Ethereum private chain
"Balcony, blockchain and robot" modern automobile thinks about the future with art
Mars weekly | NBA star Durant became the spokesperson of coinbase brand; Solana launched $150 million chain game fund
First class position: in depth interpretation of decentralized trading platform Bancor
The current situation of Dao: investigating Dao ecology from community construction, governance and world integration under the chain
- Technology weekly · why is Web3 related to blockchain
- Blockchain mainstream consensus mechanism
- Technical magic of blockchain
- Decentralized Oracle adameral blockchain data interaction Middleware
- Is it difficult to settle claims in hospital? Blockchain technology realizes "report upon hospitalization and compensation upon discharge"
- Implement the national standardization development outline and put the blockchain on a standardized path
- Understand pledge as service: opportunities and risks, current situation and future
- Talk about Web3 Decentralized work: will the Internet create human prosperity?
- Vitalik: how to improve the transaction anti censorship of the block proposer's scheme
- [Hackathon] BSV programming marathon champion plan to build a dynamic bitcoin network
- Research Report on Solana: practical applications, advantages and challenges
- A hundred flowers bloom in application, presenting the five pole pattern of North Zhejiang, Jiangsu, Shanghai and Guangdong - industrial application of China's blockchain industry development report in 2021
- Popular science article ｜ can Ethereum and Boca use the same address? Moonbeam "unified account" helps you achieve
- Bloomberg 2022 encryption Outlook: the "fate" of bitcoin, Ethereum and encrypted dollar
- Sailian blockchain education provides block chain technology training for Weichai Power
- Sailian blockchain Education: does the school district blockchain have a future?
- Is the development of school district block chain promising?
- Sailian blockchain education was invited to give a training lecture on blockchain technology in Shandong science and engineering district
- To learn blockchain technology, let's build a group school district blockchain technology
- School district block chain technology, what do you learn? Blockchain training institutions or self-study?
- What exactly does blockchain learning learn? Do you need to go to blockchain training institutions?
- Review of dimitra and Morpheus AMA, global blockchain agricultural technology platform
- Bitcoin public key principle
- Blockchain application series - did
- Bitcoin series - using docker to build BTC private chain
- Bitcoin series - BTC synchronous public chain, test chain and private chain
- Bitcoin series - BTC compilation and installation
- Ethereum series - Web3 js
- Experience - deploy Ethereum private chain (POA)
- Experience part - deploying Ethereum private chain (POW)
- Ethereum series - Smart contract development and commissioning
- Ethereum series - DAPP development three swordsman
- IPFs series - combination of IPFs and blockchain
- How can the Internet of things, big data, cloud computing, blockchain and artificial intelligence be combined to promote the development of digital economy?
- The form of story telling tells you what is server, cloud deployment, virtualization, artificial intelligence, blockchain, cloud computing, big data and privacy computing
- Open source Hongmeng, metauniverse, blockchain, open source collection | alot open source science and technology festival and openharmony technology forum are in hot registration
- Bankless year-end summary: encrypted network will subvert the old power system
- The other side of Dao: bribery in the chain and the rise of dark Dao
- The first 3D chain game (CSC) of metauniverse concept seeks token in encrypted world and blockchain game
- Metauniverse 3D [NFT] arrg mobile game of metauniverse blockchain [Curtis sword]