# ethereum-offline-sign

> Sign the ETH smart contract transaction offline

Latest version **1.0.2** (published 2018-10-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install ethereum-offline-sign
pnpm add ethereum-offline-sign
yarn add ethereum-offline-sign
bun add ethereum-offline-sign
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-10-12 |
| First published | 2018-10-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 33.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 18 |
| Author | drunken |
| Maintainers | drunken |
| Keywords | Ethereum, Coinxp, Contract, Signature |

## Links

- npm: https://www.npmjs.com/package/ethereum-offline-sign
- Repository: https://github.com/drunken005/ethereum-offline-sign
- Homepage: https://github.com/drunken005/ethereum-offline-sign#readme
- Issues: https://github.com/drunken005/ethereum-offline-sign/issues
- npm.io page: https://npm.io/package/ethereum-offline-sign

## Dependencies (6)

- [utf8](https://npm.io/package/utf8.md) ^3.0.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.9-1
- [bignumber.js](https://npm.io/package/bignumber.js.md) git+https://github.com/frozeman/bignumber.js-nolookahead.git
- [ethereumjs-tx](https://npm.io/package/ethereumjs-tx.md) ^1.3.7
- [multi-wallet-sig](https://npm.io/package/multi-wallet-sig.md) ^1.0.1

## Recent versions

- 1.0.2 (latest) — 2018-10-12
- 1.0.1 — 2018-10-12
- 1.0.0 — 2018-10-11

## 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](https://github.com/drunken005/offline-multiSigWallet-demo)

## Get Started
```bash
npm install ethereum-offline-sign --save
```
## Test
```bash
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:
```bash
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:
```bash
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:
```bash
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:
```bash

etherSigner.getAddress()
// 0x01bf9878a7099b2203838f3a8e7652ad7b127a26
```

---
_Source: https://npm.io/package/ethereum-offline-sign · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
