GithubHelp home page GithubHelp logo

mingderwang / truffle-hdwallet-provider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trufflesuite/truffle-hdwallet-provider

0.0 3.0 0.0 21 KB

HD Wallet-enabled Web3 provider

JavaScript 100.00%

truffle-hdwallet-provider's Introduction

truffle-hdwallet-provider

HD Wallet-enabled Web3 provider. Use it to sign transactions for addresses derived from a 12-word mnemonic.

Install

$ npm install truffle-hdwallet-provider

Requirements

Node >= 7.6

General Usage

You can use this provider wherever a Web3 provider is needed, not just in Truffle. For Truffle-specific usage, see next section.

var HDWalletProvider = require("truffle-hdwallet-provider");
var mnemonic = "mountains supernatural bird..."; // 12 word mnemonic
var provider = new HDWalletProvider(mnemonic, "http://localhost:8545");

// Or, alternatively pass in a zero-based address index.
var provider = new HDWalletProvider(mnemonic, "http://localhost:8545", 5);

By default, the HDWalletProvider will use the address of the first address that's generated from the mnemonic. If you pass in a specific index, it'll use that address instead. Currently, the HDWalletProvider manages only one address at a time, but it can be easily upgraded to manage (i.e., "unlock") multiple addresses.

Parameters:

Parameter Type Default Description
mnemonic string null 12 word mnemonic which addresses are created from.
provider_uri string null URI of Ethereum client to send all other non-transaction-related Web3 requests
address_index number 0 If specified, will tell the provider to manage the address at the index specified
num_addresses number 1 If specified, will create number addresses when instantiated
shareNonce boolean true If false, a new WalletProvider will track its own nonce-state

Truffle Usage

You can easily use this within a Truffle configuration. For instance:

truffle.js

var HDWalletProvider = require("truffle-hdwallet-provider");

var mnemonic = "mountains supernatural bird ...";

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    },
    ropsten: {
      // must be a thunk, otherwise truffle commands may hang in CI
      provider: () =>
        new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"),
      network_id: '3',
    }
  }
};

truffle-hdwallet-provider's People

Contributors

alex-miller-0 avatar cgewecke avatar gnidan avatar mattgstevens avatar tcoulter avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.