Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to translate and explain web3.js documents in Ethernet Square

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about how to translate and explain web3.js documents in Ethernet Square. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

Web3 introduction

Web3 is a set of API that communicates with Ethernet Fong nodes. If we need to develop decentralized applications based on Ethernet Square, we must understand web3, for example, we need to use Web3 to obtain node status, account information, call contracts, monitor contract events, and so on.

Note: the smart contract runs on the virtual machine provided by the node, so calling the smart contract also needs to send a request like the node.

Web3 actually encapsulates the JSON-RPC interface exposed by the node, and it has multiple language versions of the implementation:

JavaScript Web3.js

Python Web3.py

Haskell hs-web3

Java web3j

Scala web3j-scala

Purescript purescript-web3

PHP web3.php

PHP ethereum-php

Web3.js release not

There are two incompatible versions of web3.js: 0.20.x and 1.0 beta, which refactored version 0.20 and introduced Promise to simplify asynchronous programming and avoid layers of callback nesting.

To make a comparison, use two versions to get the current block number:

/ / version 0.20 web3.eth.getBlockNumber (function callback (err, value) {console.log ("BlockNumber:" + value)}); / / version 1.0 web3.eth.getBlockNumber () .then (console.log)

Let's take a look at obtaining the account balance:

/ / version 0.20 web3.eth.getAccounts (function callback1 (error, result) {web3.eth.getBalance (result [0], function callback2 (error, value) {console.log ("value" + value);}) / / version 1.0 web3.eth.getAccounts (). Then (res) = > web3.eth.getBalance (res [0]). Then (value) = > console.log (value))

Using version 1.0 is a bit simpler than version 0.2, and it's important to note that most of web3's interfaces are called asynchronously, and usually the last parameter is a callback function.

After reading the above, do you have any further understanding of how to translate and explain the web3.js documents of Ethernet Square? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report