Skip to content

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

License

Notifications You must be signed in to change notification settings

Heisem/contract-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published