JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q32849F
  • License MIT

Provides easy mechanism for creating, and signing transactions offline

Package Exports

  • eth-offline-tx

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eth-offline-tx) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Eth-Offline-Tx

This project is licensed under the terms of the MIT license.

(WIP) Not guaranteed to work for all use cases. But its heading in that direction.

Installation

npm install eth-offline-tx

Description

The purpose here is to simplify creating and signing offline ethereum transactions into two easy functions:

  • createOfflineTransaction({<txn_details>})
  • signOfflineTransaction(txn, {<credentials>})

Requirements

You will need to provide the following info:

  • HttpProvider for the Ethereum client
  • Wallet & Password OR credentials (public/private key)

Additionally if you are making a smart contract transaction:

  • ABI Definition
  • Contract Address

Usage

const EthOfflineTx = require('eth-offline-tx');

let provider = 'https://rinkeby.infura.io/<token_redacted>';
const eoff = new EthOfflineTx(provider);

// Create the offline transaction
eoff.createOfflineTransaction({
  from:'<public_key_redacted>',
  to:'<contract_address_redacted>', 
  abi: abi, 
  method: 'voteForCandidate', 
  args: ['ThisGuy'],
  gasPrice: '55',
  gas: 400000,
  value: 0
})

// Sign the offline transaction with either wallet & password,
//   or by passing in the private key directly
.then(txn => {
  let signedTransaction;

  signedTransaction = eoff.signOfflineTransaction(txn, 
    {wallet: '/path/to/wallet', password: '<password>'});

  //     -- OR using credentials directly --

  signedTransaction = eoff.signOfflineTransaction(txn, 
    {privateKey: '<private_key>'});

  // send signed transaction and wait for the receipt!

  // Example using web3:
  eoff.w3.eth.sendSignedTransaction(signedTransaction)
    .on('receipt', console.log);
});