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 use web3.eth.sign

2025-04-03 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 web3.eth.sign". In daily operation, I believe many people have doubts about how to use web3.eth.sign. The editor 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 about "how to use web3.eth.sign". Next, please follow the editor to study!

Using the specified account to sign the data to be sent, the account needs to be unlocked.

Call:

Web3.eth.sign (address, dataToSign, [, callback])

Parameters:

Address: String-the address used by the signature

DataToSign: String-data to be signed

Callback: Function-(optional) callback function to support asynchronous execution of 7.

Return value:

String-the signed data.

The returned value corresponds to the signed string of ECDSA (Elliptic Curve Digital Signature Algorithm).

R = signature [0:64] s = signature [64VR 128] v = signature [128 VR 130]

It is important to note that if you use ecrecover, the v value here is 00 or 01, so if you want to use them, you need to convert the v value here to an integer, plus 27. Eventually the value you want to use will be 27 or 2813.

Example:

Var result = web3.eth.sign ("0x135a7de83802408321b74c322f8558db1679ac20", "0x9dd2c369a187b4e6b9c402f030e50743e619301ea62aa4c0737d4ef7e10a3d49"); / / second argument is web3.sha3 ("xyz") console.log (result); / / "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400" this ends the study of "how to use web3.eth.sign", hoping to solve everyone's 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.

Share To

Internet Technology

Wechat

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

12
Report