# ethereumjs-tx-keyvault

> Azure Key Vault extensions for ethereumjs-tx

Latest version **1.0.6** (published 2018-02-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install ethereumjs-tx-keyvault
pnpm add ethereumjs-tx-keyvault
yarn add ethereumjs-tx-keyvault
bun add ethereumjs-tx-keyvault
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2018-02-14 |
| First published | 2018-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Tomislav Markovski |
| Maintainers | tmarkovski |
| Keywords | ethereum, keyvault |

## Links

- npm: https://www.npmjs.com/package/ethereumjs-tx-keyvault
- Repository: https://github.com/tmarkovski/ethereumjs-tx-keyvault
- Homepage: https://github.com/tmarkovski/ethereumjs-tx-keyvault#readme
- Issues: https://github.com/tmarkovski/ethereumjs-tx-keyvault/issues
- npm.io page: https://npm.io/package/ethereumjs-tx-keyvault

## Dependencies (5)

- [bn.js](https://npm.io/package/bn.js.md) ^4.11.8
- [secp256k1](https://npm.io/package/secp256k1.md) ^3.5.0
- [underscore](https://npm.io/package/underscore.md) ^1.8.3
- [ethereumjs-tx](https://npm.io/package/ethereumjs-tx.md) ^1.3.3
- [azure-keyvault](https://npm.io/package/azure-keyvault.md) ^3.0.0-preview

## Recent versions

- 1.0.6 (latest) — 2018-02-14
- 1.0.5 — 2018-02-13
- 1.0.4 — 2018-02-13
- 1.0.3 — 2018-02-13
- 1.0.2 — 2018-02-13
- 1.0.1 — 2018-02-13
- 1.0.0 — 2018-02-13

## README

# Extensions to ethereumjs-tx adding transaction signing support using Azure Key Vault
[![Build Status](https://travis-ci.org/tmarkovski/ethereumjs-tx-keyvault.svg?branch=master)](https://travis-ci.org/tmarkovski/ethereumjs-tx-keyvault)
## Installation
`npm install ethereumjs-tx-keyvault`

## Example usage

````javascript
const txExt = require("ethereumjs-tx-keyvault")
const KeyVault = require("azure-keyvault")
const EthereumTx = require("ethereumjs-tx")
const AuthenticationContext = require("adal-node").AuthenticationContext;

const clientId = "<to-be-filled>";
const clientSecret = "<to-be-filled>";
const vaultUri = "<to-be-filled>";

// Setup key vault client and credentials
const authenticator = function (challenge, callback) {
    const context = new AuthenticationContext(challenge.authorization);
    return context.acquireTokenWithClientCredentials(challenge.resource, clientId, clientSecret, function (err, tokenResponse) {
        if (err) throw err
        const authorizationValue = tokenResponse.tokenType + ' ' + tokenResponse.accessToken
        return callback(null, authorizationValue)
    })
}
const credentials = new KeyVault.KeyVaultCredentials(authenticator)
const client = new KeyVault.KeyVaultClient(credentials);

// Create a sample transaction
const txParams = {
    nonce: '0x00',
    gasPrice: '0x09184e72a000',
    gasLimit: '0x2710',
    to: '0x0000000000000000000000000000000000000000',
    value: '0x00',
    data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
    // EIP 155 chainId - mainnet: 1, ropsten: 3
    chainId: 3
}
const tx = new EthereumTx(txParams)

// Sign the transaction and log verification results
txExt.sign(tx, client, vaultUri, "alice", "")
    .then(signature => {
        Object.assign(tx, signature)
        console.log("Signature verification: " + tx.verifySignature())

        // Print transaction hash. Can be sent directly to geth using 'sendRawTransaction'
        const txHash = "0x" + Buffer.from(tx.serialize()).toString("hex")
        console.log("Transaction hash: " + txHash)
    })
  ````

## .NET backend support for Key Vault
Check out the samples in F# for .NET standard

[https://github.com/tmarkovski/ethereum-key-vault](https://github.com/tmarkovski/ethereum-key-vault)

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