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

ethereum-offline-sign

v1.0.2

Published

Sign the ETH smart contract transaction offline

Downloads

6

Readme

Ethereum offline sign

Ethereum transaction offline signature tool

About

Sign offline for the ETH transaction and smart contract call message transaction, return transaction data in HEX format. This allows you full control over your account's private key without having to unlock it at the ethereum node

Demo code

Get Started

npm install ethereum-offline-sign --save

Test

npm test

APIS

transferSign(nonce, to, value) Ordinary transactions are signed offline

Inputs
  • nonce Sender nonce
  • to The destination address of the message, left undefined for a contract-creation transaction.
  • value The value transferred for the transaction in Wei
Return value

Signed transaction data in HEX format

Example:

var EtherSigner = require('ethereum-offline-sign');
var gasPrice = web3.eth.gasPrice,
	gasLimit = 4000000;
	sender = '0x01BF9878a7099b2203838f3a8E7652Ad7B127A26';
	senderPrivateKey = '0x01BF9878a7099b2203838f3a8E7652Ad7B127A26';
	destination = '0x6CE18EA1f852367f3fB6b4ad76D58f65374D9920';
    nonce = await web3.eth.getTransactionCount(sender);
    value = etherSigner.toWei(0.1, 'ether');
    
//Instantiation EtherSigner
var etherSigner = new EtherSigner(null, senderPrivateKey, gasPrice, gasLimit);

//Sign transactions offline, return signed transaction data in HEX format
var sigTx = etherSigner.transferSign(nonce, destination, value);
web3.eth.sendRawTransaction(sigTx);

deployContractSign(contract, arguments, nonce) Sign the deployed contracts

Inputs
  • contract Contains contract instances of the abi, eg:web3.eth.contract(Contract.abi);
  • arguments Contract constructor parameters, Type array
  • nonce Contract creator nonce
Return value

Signed transaction data in HEX format

Example:

var relayContract = require('./contracts/RelayWallet.sol.js');
var contract = web3.eth.contract(relayContract.abi);
var params = [
        destination, 
        {
            data: relayContract.bytecode,
            gas: gasLimit,
            from: sender
        }
    ];
//Sign deploy contract offline, return signed transaction data in HEX format
var sigTx = etherSigner.deployContractSign(contract, params, nonce);
web3.eth.sendRawTransaction(sigTx);

contractTransferSign(method, arguments, to, nonce, value) Sign the contract function call

Inputs
  • method Contract function
  • arguments Contract function args, Type array
  • to Contract address
  • nonce Sender account nonce
  • value ETH amount, default 0
Return value

Signed transaction data in HEX format

Example:

var relayContract = require('./contracts/RelayWallet.sol.js');
//relayAddress is delpoyed contract address
let relayWallet = web3.eth.contract(relayContract.abi).at(relayAddress);
let etherSigner = new EtherSigner(relayWallet, senderPrivateKey, gasPrice, gasLimit);
var params = [
        {
        	gasPrice,
            gas: gasLimit,
            from: sender
        }
    ];
//Sign deploy contract offline, return signed transaction data in HEX format
var sigTx = etherSigner.contractTransferSign('withdrawToDest', params, relayAddress, nonce, 0);
web3.eth.sendRawTransaction(sigTx);

getAddress()

Return value

Returns the ethereum address of a current private key

Example:


etherSigner.getAddress()
// 0x01bf9878a7099b2203838f3a8e7652ad7b127a26