Created
May 15, 2019 22:06
-
-
Save totiz/60e456bbe4faa094b68d604f80c4dd83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// โหลด web3 | |
const Web3 = require('web3') | |
// เชื่อมต่อไปยัง infura | |
const web3 = new Web3(new Web3.providers.HttpProvider(`https://kovan.infura.io/v3/${infura_token}`)) | |
// อ่านค่า nonce ณ ปัจจุบันเพื่อใช้สร้าง raw tx | |
// ค่า nonce เป็นค่า sequence number ที่จะต้องเรียงต่อกัน ตามจำนวนธุรกรรมของ address ผู้ส่ง | |
const nonce = await web3.eth.getTransactionCount(publicKey) | |
console.log('nonce', nonce) | |
// Raw tx | |
var rawTransaction = { | |
to: toAddress, | |
value: web3.utils.toWei(ethToSend, 'ether'), | |
gas: 100000, | |
gasPrice: web3.utils.toWei(gasPrice, 'gwei'), | |
nonce: nonce | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment