In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use the solidity programming language of Ethernet Square to develop intelligent contracts". In the daily operation, I believe many people have doubts about how to use the solidity programming language of Ethernet Square to develop intelligent contracts. I have consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to develop intelligent contracts using solidity programming language of Ethernet Square". Next, please follow the editor to study!
Choice of development language and development environment
At present, Solidity is the most popular programming language for smart contracts, but it is not just Solidity. As beginners, to write Solidity code, we can use Remix, which is a browser-based Soldity IDE at http://remix.ethereum.org/. Remix supports writing, testing, and deploying smart contracts.
Write code
There is no doubt that the first program for learning a language is HelloWorld, so let's write a smart contract for HelloWorld. The contract code is as follows.
Pragma solidity ^ 0.4.21 leading contract HelloWorld {string hello = "HelloWorld!!"; event say (string _ value); function sayHello () public {emit say (hello);}}
The first line of the contract code specifies that the contract uses a Solidity version of 0.4.21, and Solidity features higher than 0.4.21 are not supported.
In Solidity, the contract keyword contains a code snippet that represents a smart contract, and it has member variables that represent the contract's data, such as hello in our HelloWorld, which we can modify and manipulate. At the same time, it has some function that can be called by others.
Event is an event and subscription mechanism provided by Solidity. Intelligent contracts can issue some event, and contract callers can listen to these events and respond accordingly.
This contract doesn't do much, it just emits a say event when someone calls its sayHello method. Next, let's deploy and execute it.
Deploy and run contracts
First of all, we need to compile this code. There is a tab of Compile on the right of Remix. Click Start to compile to compile successfully. If it fails, there will be an error prompt and you can correct it.
Then we need to deploy it to the blockchain and switch from tab to Run.
Remix supports three types of environment operating contracts. If JavaScript VM, the co-appointment is performed in the browser JavaScript sandbox block chain, which can be understood to mean that Remix uses the browser's JS environment to virtualize a blockchain virtual machine. If Injected Provider, Remix will link blockchain wallets such as Matamask or Mist to deploy and invoke contracts indirectly. Finally, Web3 Provider,Remix will link remote zone connection nodes such as Geth to deploy and invoke the contract.
For simplicity, we will use JavaScript VM, which will initialize five blockchain accounts for us, using the default account. Set Environment to JavaScript VM. As shown below:
In the image above, in addition to Environment and Account down in turn, we will be able to see Gas Limit, which is the maximum price we can accept to execute a Transaction. Value indicates how much ether we will transfer to the contract account in the next call.
The next HelloWorld represents the contract we will create. Click Create to create the contract. In the figure below, we see that the HelloWorld contract has been created.
We can click sayHello to call. You can see that the call has been successful and the event we issued is printed out in logs.
At this point, the study on "how to develop an intelligent contract using the solidity programming language of Ethernet Square" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.