All Projects → blockmason → web3-provider-ledger

blockmason / web3-provider-ledger

Licence: MIT license
A web3 provider for Ledger hardware wallets

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to web3-provider-ledger

Frame
System-wide Web3 for macOS, Windows and Linux
Stars: ✭ 225 (+1400%)
Mutual labels:  ledger, web3
ethjs-extras
All your dApp / App essentials for working with Ethereum.
Stars: ✭ 17 (+13.33%)
Mutual labels:  web3, ethjs
awesome-crypto-critique
Making sense of web3 & crypto. Introduction to key concepts and ideas. Rigorous, constructive analysis of key claims pro and con. A look at the deeper hopes and aspirations.
Stars: ✭ 1,127 (+7413.33%)
Mutual labels:  web3
emerald-web3-gateway
The Web3 Gateway for the Oasis Emerald ParaTime.
Stars: ✭ 19 (+26.67%)
Mutual labels:  web3
niftygate
Drop-in Access Control via NFT Ownership
Stars: ✭ 61 (+306.67%)
Mutual labels:  web3
ethereum-hdwallet
CLI and Node.js library for Ethereum HD Wallet derivations from mnemonic
Stars: ✭ 44 (+193.33%)
Mutual labels:  web3
datamodels
A collection of data models used by Ceramic applications
Stars: ✭ 66 (+340%)
Mutual labels:  web3
project web3.0
This is a code repository for the corresponding video tutorial. In this video, we're going to build a Web 3.0 React Solidity Blockchain Application
Stars: ✭ 2,690 (+17833.33%)
Mutual labels:  web3
multisol
CLI application for verifying Solidity contracts on Etherscan
Stars: ✭ 94 (+526.67%)
Mutual labels:  web3
etherbrite
🗓 Clone eventbrite on Ethereum, built in Solidity, TruffleJS, Web3js and React/Redux.
Stars: ✭ 19 (+26.67%)
Mutual labels:  web3
attestation
Paper and implementation of blockchain attestations
Stars: ✭ 44 (+193.33%)
Mutual labels:  web3
vscode-ledger
Visual Studio Code support for Ledger files
Stars: ✭ 18 (+20%)
Mutual labels:  ledger
nft-app
How to create your own NFT and mint NFT token
Stars: ✭ 145 (+866.67%)
Mutual labels:  web3
ape
The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
Stars: ✭ 339 (+2160%)
Mutual labels:  web3
eth-commerce
Javascript library to accept ethereum payments on any website
Stars: ✭ 24 (+60%)
Mutual labels:  web3
web3-webpacked
Drop-in web3 solution for single-page Ethereum dApps
Stars: ✭ 36 (+140%)
Mutual labels:  web3
ethereum-java-web3j
一个很受欢迎的用java和android app类库web3j开发区块链以太坊dapp和智能合约的教程。内容涉及以太坊核心概念,如账户管理、状态与交易、合约开发与交互、过滤器和事件等,也详细说明如何用web3j开发接口与以太坊交互。
Stars: ✭ 22 (+46.67%)
Mutual labels:  web3
cybaca
Small app for huge community growth
Stars: ✭ 16 (+6.67%)
Mutual labels:  web3
openst-platform
OpenST Platform provides an interface to tokenise mainstream consumer applications with crypto-assets on Ethereum [deprecated in favour of openst.js and mosaic.js]
Stars: ✭ 84 (+460%)
Mutual labels:  web3
ledger
🏛 A programmable financial ledger that makes complex money flows easy
Stars: ✭ 267 (+1680%)
Mutual labels:  ledger

Ledger web3 Provider

CircleCI npm version npm downloads dependencies devDependencies license

This web3 provider allows Ethereum transactions to be signed with a Ledger device.

Features

  • Lightweight, with minimal dependencies
  • Easy to use; just plug it in wherever a web3 provider is expected

Installing

Yarn:

$ yarn add web3-provider-ledger

npm:

$ npm install --save web3-provider-ledger

Usage

Let's assume we are using the ethjs library. This library, like Web3, is designed to be constructed with an instance of a web3 provider.

import Eth from 'ethjs';
import LedgerProvider from 'web3-provider-ledger';

const eth = new Eth(new LedgerProvider());

That's all you need to do in order to get an instance of ethjs, but this particular instance is only capable of generating signed transactions.

Here's one way you might end up with a transaction for interacting with a smart contract:

// Use the ethjs contract API to build a convenience wrapper for a contract
const myContract = eth.contract(myContractAbi).at(myContractAddress);

// Get the raw signed transaction
const tx = await myContract.myFunction(...myFunctionArgs);

At this point, tx gives us a signed transaction. We still need to send the transaction, which requires a network-capable provider. For this, you can use the built-in Eth.HttpProvider or look for an injected provider via the global web3.currentProvider.

Here's what this might look like:

// Constract a network-capable instance of ethjs
const ethNet = new Eth(web3.currentProvider);

// Use the network-capable provider to *send* the transaction
const txId = await ethNet.sendRawTransaction(tx);

Usage with ethjs-signer-provider

import Eth from 'ethjs';
import LedgerDevice from 'web3-provider-ledger/ledger-device';
import SignerProvider from 'ethjs-provider-signer';

const ledgerDevice = new LedgerDevice({ appId: origin, u2f });

const provider = new SignerProvider('https://ropsten.infura.io', {
  signTransaction: async (transaction, callback) => {
    const signedTransaction = await ledgerDevice.signTransaction(transaction);
    callback(null, signedTransaction);
  },
  accounts: async (callback) => {
    const accounts = await ledgerDevice.listAddresses();
    callback(null, accounts);
  }
});

const eth = new Eth(provider);

// `eth` is now configured to use the Ledger device for signing and
// Infura for sending transactions to the Ethereum network

Advanced Usage

See the API Reference for detailed code-level documentation.

In addition to the provider, this library includes a LedgerDevice, which allows operations to be performed directly on the device. This can be useful for account discovery (LedgerDevice#listAddresses()), which can be used to allow users to choose which account they would like to use. The index of the preferred account can then be provided to a new device via the accountIndex attribute, and this device can be given to LedgerProvider via its device attribute.

For example, here is how you might get a list of account addresses on the device:

import LedgerDevice from 'web3-provider-ledger/device';

const device = new LedgerDevice({ appId: origin, u2f });
const accounts = await device.listAddresses();

Let's say the user has selected the account at index 3. To use that account, you would then construct the provider as follows:

import Eth from 'ethjs';
import LedgerDevice from 'web3-provider-ledger/device';
import LedgerProvider from 'web3-provider-ledger';

// Simple form
const eth = new Eth(new LedgerProvider({ accountIndex: 3 }));

// Advanced form (equivalent result to the simple form above)
const eth = new Eth(new LedgerProvider({
  device: new LedgerDevice({ accountIndex: 3, appId: origin, u2f })
}));

Contributing

See CONTRIBUTING.md.

Code of Conduct

See CODE_OF_CONDUCT.md.

Security

See SECURITY.md.

License

This library is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].