contract-utils

0.1.25 • Public • Published

contract-utils

Contract utility library for Ethereum, to easily sign and send raw transactions

npm version Build Status dependencies Status devDependencies Status Coverage Status

Installation:

  • npm install contract-utils --save

How to use:

const { Transaction } = require('contract-utils');
const contracts = {
  'erc20'{ // contract name
    address: '', // contract address
    abi: [], // contract abi
  },
};
const Transaction = new Transaction('http://localhost:8545', contracts);
 
// Example signing and sending transaction to a custom ERC20 contract
const txData = {
  contractName: 'erc20', // contract name from 'contracts' object
  privateKey: 'privateKey', // private key to sign the transaction
  gasLimit: 200000, //   optional: (default: 200000)
  value: 0, // optional value sent in ether (wei) if function is 'payable' (default: 0)
};
Transaction.send(
  txData,
  'transfer', // method to be called in the contract
  '0x...', // @param1
  1000000000000000000, // @param2
  // ...other params
)
.then(console.log);

Readme

Keywords

Package Sidebar

Install

npm i contract-utils

Weekly Downloads

2

Version

0.1.25

License

ISC

Unpacked Size

20 kB

Total Files

10

Last publish

Collaborators

  • heisem