https://ethereum.stackexchange.com/questions/12823/proper-transaction-signing const Web3 = require('web3'); const Tx = require('ethereumjs-tx'); const config = require('./config'); const web3 = new Web3(new Web3.providers.HttpProvider(config.provider)); //link provided by Infura.io web3.eth.defaultAccount = "0xc929c890f1398d5c1ecdf4f9ecec016906ac9f7f"; const getNonce = () => { return new Promise((resolve, reject) => { web3.eth.getTransactionCount(web3.eth.defaultAccount, (error, result) => { if(error) reject(error); resolve(web3.toHex(result)); }) }) } const getGasPrice = () => { return new Promise((resolve, reject) => { web3.eth.getGasPrice((error, result) => { if(error) reject(error); resolve(web3.toHex(result.toNumber())); }) }) } const sendRawTransaction = (rawTx) => { const privateKey = "190b820c2627f26fd1b973b72dcba78ff677ca4395c64a4a2d0f4ef8de36883c"; const tx = new Tx(rawTx); const privateKeyBuffer = Buffer.

繼續閱讀

ring buffer

https://zhen.org/blog/ring-buffer-variable-length-low-latency-disruptor-style/ https://github.com/smartystreets-prototypes/go-disruptor

繼續閱讀

https://ethereum.stackexchange.com/questions/50042/why-does-sendsignedtransaction-return-a-tx-hash-but-does-not-post-to-the-rinkeby window.web3 = new Web3(new Web3.providers.HttpProvider(endpoint)); sendEther() { const fromAccount = **acct1**; const toAccount = **acct2**; const rawTransaction = this.makeRawTransaction(fromAccount, toAccount); const signedTransaction = this.makeSignedTransaction(rawTransaction); const serializedTransaction = `0x${signedTransaction.serialize().toString('hex')}`; window.web3.eth.sendSignedTransaction(serializedTransaction, (error, result) => { if(!error) { console.log(`Transaction hash is: ${result}`); this.setState({ etherscanUrl: `https://rinkeby.etherscan.io/tx/${result}`, error: null }); } else { this.setState({ error: error.message }) console.error(error); } }); } makeSignedTransaction(rawTransaction) { const privateKey = '**************'; const privateKeyX = new Buffer(privateKey, 'hex'); const transaction = new EthTx(rawTransaction); transaction.

繼續閱讀

geth attach

geth --exec "eth.blockNumber" attach --datadir ./ geth --exec "eth.syncing" attach --datadir ./ geth --exec "admin.peers" attach --datadir ./ geth --exec "clique.getSnapshot()" attach --datadir ./ watch -n 2 'geth --exec "clique.getSnapshot()" attach --datadir ./'

繼續閱讀

geth-prometheus

https://github.com/karalabe/geth-prometheus https://blog.ethereum.org/2019/07/10/geth-v1-9-0/ You can quickly reproduce the above charts via my clone of Maxim Krasilnikov’s project by running docker-compose up in the repo root and accessing http://localhost:3000 with the admin/admin credentials. Alternatively, you can view my testing snapshot on Raintank, or import this dashboard into your own Grafana instance

繼續閱讀

geth console ## get balance eth.getTransaction("") eth.getTransactionReceipt("") EX: transaction id 0x8dfaa1b5d2e660ee2d3aa9fd0eeb33cc726d50122790e882a914ffd7d02e3a83 eth.getTransaction(“0x8dfaa1b5d2e660ee2d3aa9fd0eeb33cc726d50122790e882a914ffd7d02e3a83”) eth.getTransactionReceipt(“0x8dfaa1b5d2e660ee2d3aa9fd0eeb33cc726d50122790e882a914ffd7d02e3a83”) ## get transaction count eth.getTransactionCount() eth.getTransactionCount(, “pending”) EX: transaction id 0x8dfaa1b5d2e660ee2d3aa9fd0eeb33cc726d50122790e882a914ffd7d02e3a83 eth.getTransactionCount(“0x8dfaa1b5d2e660ee2d3aa9fd0eeb33cc726d50122790e882a914ffd7d02e3a83”) eth.getTransactionCount(“0x8dfaa1b5d2e660ee2d3aa9fd0eeb33cc726d50122790e882a914ffd7d02e3a83”, “pending”) ## check pending queued txpool.status EX: { pending: 0, queued: 5 }

繼續閱讀

ethereum 交易 驗證

https://www.blocktempo.com/blockchain-technical-overview-structure-of-blockchain-ethereum/ 3. 以私鑰簽署交易。 4. 廣播「加上簽名的交易封包」至鄰近的以太坊節點們。 https://ithelp.ithome.com.tw/m/articles/10215095 總而言之在區塊鏈接納這筆交易前,先試著用地址反推回原本的公鑰,再用公鑰解密當初這筆交易紀錄的簽章看看,如果公鑰解的開就可以代表是公鑰持有人本人所簽核的,這便是剛剛提到的"數位簽章"。 注意:這段比較像是一般加解密的方式,好像不是ethereum https://ethereum.stackexchange.com/questions/13778/get-public-key-of-any-ethereum-account ethereum 簽完的東西 可以 找出 public key 有public key 就可以知道是誰發出這個交易 https://zhuanlan.zhihu.com/p/30481292 签名完成了,我们如何验证某些签名后的数据是哪个账户签名的呢?在web3.js 发布1.0版本以前,验证签名只能通过智能合约的ecrecover函数来实现。新版的web3.js提供了web3.eth.accounts.recover函数用于验证签名。这里我们仍然使用传统的智能合约ecrecover方式。 ecrecover接收数据的哈希值以及r/s/v等参数作为输入,返回实施该签名的账户地址。因此我们只需要通过合约拿到实施签名的地址,和我们真正的地址进行对比,如果地址一致,就说明验证通过了。 這也是ethereum private key和address比較重要的原因了 https://learnblockchain.cn/books/geth/part3/sign-and-valid.html

繼續閱讀

作者的圖片

Sue boy

Sueboy Can support You

CIO

Taiwan