简体   繁体   中英

How to hide private key in web3.js

I want to send signTransaction using web3, the problem is that for doing that, I need to use the privateKey of my Metamask account. Anyone could see the "privatekey" from explorer.

So how can I hide this variable in javascript for using it safety? The line of code in javascript in frontend is the following:

web3.eth.accounts.signTransaction(rawTransaction, privateKey)

I would like to store the privatekey in backend and make a call to backend to obtain it, how should I do it in a safe way?

You are using blockchain wrong.

Make users to sign the transaction with their own private key. Furthermore MetaMask never exposes the private key in the browser in the first place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM