Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethereumjs-tx-keyvault

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-tx-keyvault

Azure Key Vault extensions for ethereumjs-tx

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Extensions to ethereumjs-tx adding transaction signing support using Azure Key Vault

Build Status

Installation

npm install ethereumjs-tx-keyvault

Example usage

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

Keywords

FAQs

Package last updated on 14 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc