請教ETH的公鑰簽名問題 - 數位貨幣

Table of Contents

直接建一個可以run node.js的環境import web3.js

var web3 = new Web3(new Web3.providers.HttpProvider('rpc位址'));
//連結rpc

var privateKey = '0x你的私鑰'

var tx = {
gasPrice: '0x瓦斯費',
gasLimit: '0x瓦斯上限',
to: '0x發送地址或合約',
value: '0x主鏈幣金額',
data: '0x00'
//純傳弊用0x00合約互動要
//call methods.myMethod.encodeABI
}
//設定tx內容

var signed = web3.eth.accounts.signTransaction(tx,privateKey)
//用私鑰簽名

web3.eth.sendSignedTransaction(signed. rawTransaction)
//廣播交易

基本的簽名廣播流程大概是這樣,只要web3.js支援的鏈都可以這樣做。
Good luck
----
Sent from BePTT on my iPhone 11

--

All Comments

Rebecca avatarRebecca2022-02-05
這次不出作業了?
Hedy avatarHedy2022-02-09
出作業會被以為是詐騙QQ
Dinah avatarDinah2022-02-05
這就標準的web3.js連endpoint簽交易
有可能做成離線簽章版本嗎?
Daph Bay avatarDaph Bay2022-02-09
順便問一下私鑰保存在本地不需要加密嗎
Todd Johnson avatarTodd Johnson2022-02-05
to 黑鴨簽名那一個指令可以離線簽,
然後再藍芽or QR or手抄傳到有聯網的機器廣播
Eden avatarEden2022-02-09
web3.eth.accounts.signTransaction
有沒有連到rpc都可以用
Queena avatarQueena2022-02-05
To Inonai那就看你的架構,如果離線簽名有沒有加密就沒差
Bethany avatarBethany2022-02-09
感謝說明
Agatha avatarAgatha2022-02-05
感謝大家的回應,紅包已發 :)