Hello,
When a button is pressed, I send custom tokens to the user using the code below by signing and sending it from my account. The code works perfectly, however, how do I safely store and retrieve the “private key”? The code below is stored in a plain javascript file.
web3.eth.accounts.signTransaction(rawTransaction, "**MY PRIVATE KEY HERE**")
.then(signedTx => web3.eth.sendSignedTransaction(signedTx.rawTransaction))
.then(req => {
/* The trx was done. Write your actions here. For example, getBalance. */
getTokenBalanceOf(userAddress).then( balance => { console.log(userAddress + " Token Balance: " + balance); });
addCustomTokensToUsersMetaMask();
customTokenTransferCompleted();
return true;
})
However, how do I store this private key safely and retrieve it? I know there are ways like using .secret files, or storing it in environment variables, etc, but I can’t find a good tutorial on how to do it. I’m using regular html and javascript, I’m not using react.js. Thanks.