moacjs-tx
v1.1.3
Published
A simple module for creating, manipulating and signing moac transactions
Downloads
10
Readme
SYNOPSIS
INSTALL
npm install moacjs-tx
USAGE
`const Chain3 = require('chain3')
const chain3 = new Chain3(new Chain3.providers.HttpProvider('http://localhost:8545'))
const MoacTx = require('moacjs-tx')
const privateKey = XXX
const txParams = {
nonce: '0x00',
gasPrice: '0x09184e72a000',
gasLimit: '0x2710',
to: '0x0000000000000000000000000000000000000000',
value: '0x00',
data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
shardingFlag: 0,
// chainId - mainnet: 99, testnet: 101
chainId: 101
}
const tx = new MoacTx(rawTx)
const serializedTx = tx.sign(fromSecret)
chain3.mc.sendRawTransaction(serializedTx, function (err, hash) {
if (!err) {
console.log('succeed: ', hash)
return hash
} else {
console.log('error:', err)
console.log('raw tx:', rawTx)
}
})`
Note: this package expects ECMAScript 6 (ES6) as a minimum environment. From browsers lacking ES6 support, please use a shim (like es6-shim) before including any of the builds from this repo.
BROWSER
For a browser build please get from https://github.com/wanpixiaozi/moacjs-tx/blob/master/dist/moacjs-tx.min.js.