npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

moac-tx

v0.1.0

Published

An simple module for creating, manipulating and signing MOAC transactions

Downloads

5

Readme

INSTALL

npm install moac-tx

USAGE

var Chain3 = require('chain3');
var chain3 = new Chain3();

const Transaction = require('moac-tx')
const privateKey = Buffer.from('e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', 'hex')

const txParams = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000', 
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000', 
  value: '0x00', 
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'
}

const tx = new Transaction(txParams)

// EIP 155 chainId - mainnet: 99, testnet: 101
var chainId = 101;
tx.setChainId(chainid);

tx.sign(privateKey)

const serializedTx = tx.serialize()

chain3.mc.sendRawTransaction('0x'+ serializedTx.toString('hex'), function(err, hash) {
    if (!err){
        
        console.log("Succeed!: ", hash);
        return hash;
    }else{
        console.log("Chain3 error:", err.message);
        return err.message;
    }

    console.log(response);
});

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.

LICENSE

MIT

API

Creates a new MOAC transaction object.

Parameters

  • data Buffer or Array or Object a transaction can be initiailized with either a buffer containing the RLP serialized transaction or an array of buffers relating to each of the tx Properties, listed in order below in the exmple.Or lastly an Object containing the Properties of the transaction like in the Usage example.For Object and Arrays each of the elements can either be a Buffer, a hex-prefixed (0x) String , Number, or an object with a toBuffer method such as Bignum
    • data.chainId Number EIP 155 chainId - mainnet: 99, ropsten: 101
    • data.gasLimit Buffer transaction gas limit
    • data.gasPrice Buffer transaction gas price
    • data.to Buffer to the to address
    • data.nonce Buffer nonce number
    • data.shardingFlag Buffer shardingFlag, 0 - TX for MotherChain, 1 - Tx for MicroChain, default 0
    • data.via Buffer address of the VNODE proxy, only used when shardingFlag = 1
    • data.data Buffer this will contain the data of the message or the init of a contract
    • data.v Buffer EC recovery ID
    • data.r Buffer EC signature parameter
    • data.s Buffer EC signature parameter
    • data.value Buffer the amount of ether sent

Properties

  • raw Buffer The raw rlp encoded transaction

Examples

var rawTx = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000',
  value: '0x00',
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
  v: '0x1c',
  r: '0x5e1d3a76fbf824220eafc8c79ad578ad2b67d01b0c2425eb1f1347e8f50882ab',
  s: '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13'
};
var tx = new Transaction(rawTx);