当前位置:网站首页>Establishment of solid development environment

Establishment of solid development environment

2022-07-07 17:24:00 Hua Weiyun

   Catalog

How to write smart contracts on Ethereum

Set up the development environment

Write a contract

Deploy



How to write smart contracts on Ethereum

Solidity It is one of the most popular languages for developing Ethereum smart contracts , therefore , As a person who wants to become a blockchain developer , Need to learn how to use Solidity Develop smart contracts .

Set up the development environment

We're going to use IDE yes Remix, Type in the browser Remix URL. After completion , You should see an interface similar to the following :

edit


On the left side , I chose two main components . The first icon is the file browser , Here you can see all your Solidity file , The second icon is the plug-in manager , From which you can add new plug-ins . We will need to add two plug-ins , So click the plug-in manager Icon , Then input “ Solidity compiler( compiler )”. Then by clicking “Activate” Activate it , And do the same to add “Deploy and run transactions( Deploy and run transactions )” plug-in unit .

“ Solidity compiler( compiler )” Tab will allow you to configure compiler parameters and compile smart contracts , and “Deploy and run transactions( Deploy and run transactions )” The tab will allow you to deploy and interact with smart contracts in the blockchain . The list of icons should now look like this :

edit


The first thing to do is to check “ compiler ” Tab “ Automatic compilation ” Options . Next , We will configure Remix To use files in local storage .

Use the following command to install remixd:

npm install -g remixd

After installation , You can create a folder , Saved in it Solidity file , Then run the following command to tell Remix Use the files in the folder :

remixd -s <shared folder> — remix-ide https://remix.ethereum.org

edit

  Now turn to Remix The home page of , single click “Connect to localhost( Connect to local host )”, Then select... In the pop-up window “(connet) Connect ”.

edit

  And then in “File explorer( File explorer )” Under the tab, you can see a file named localhost Region . Expand it , You will see all the files contained in the shared folder from the local storage :

edit

  Have the tool to start writing the first smart contract

Remix It will provide you with a virtual blockchain environment running in the browser , First use it to deploy the contract and interact with it . Just make sure it's in “Deploy and run( Deploy and run )” Tab Javascript VM As an environment

Write a contract

edit

Deploy

single click “Deploy and run transactions( Deploy and run transactions )” tab , Then make sure you choose JavaScript VM, And select the contract name in the contract area . After completion , single click “Deploy( Deploy )”

edit

  Now? , You can “Deployed Contracts( Deployed contract )” See your contract under the area .
Expand it , You will see helloWorld function .
Click it to send the transaction that calls this function , You will see the print out hello world character string .

edit

edit


原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071522168323.html