Socket
Book a DemoInstallSign in
Socket

@coolwallets/web3-subprovider

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coolwallets/web3-subprovider

Web3 wrapper on coolwalletS sdk

latest
npmnpm
Version
0.0.1
Version published
Maintainers
3
Created
Source

Web3-Subprovoder

Introduction

Create a HookedWalletSubprovider for CoolWalletS.

This provider opens up CoolWalletS Connect as a service bridge to handle transaction signing.

Example Usage

Start Web3


// Starting web3 engine with CoolWallet Subprovider
import Web3 from 'web3'
import CoolWalletSubProvider from '@coolwallets/web3-subprovider'
import ProviderEngine from 'web3-provider-engine'
import RpcSubprovider from 'web3-provider-engine/subproviders/rpc'

const engine = new ProviderEngine()
const rpcUrl = 'https://mainnet.infura.io/v3/{your token}'

const options = {
  accountsLength: 5,
  accountsOffset: 0,
  networkId: 1
}
const coolwallet = new CoolWalletSubProvider(options)

engine.addProvider(coolwallet)
engine.addProvider(new RpcSubprovider({ rpcUrl }))
engine.start()

const web3 = new Web3(engine);

Supported Methods

  • web3.eth.getAccounts
  • web3.eth.signTransaction
  • web3.eth.sign
  • web3.eth.personal.sign
  • web3.eth.signTypedData
// Sign Transaction
function handleSignTransaction () {
  const tx = {
    "from": from,
    "nonce": "0x3b",
    "gasPrice": "0xe8754700",
    "gasLimit": "0x520c",
    "to": "0x81bb32e4A7e4d0500d11A52F3a5F60c9A6Ef126C",
    "value": "0x2386f26fc10000",
  }
  web3.eth.signTransaction(tx,(error, signed)=>{
    if(signed) {
      web3.eth.sendSignedTransaction(signed.raw, (err, hash)=>{
        if(hash) console.log(`tx hash: ${hash}`)
      })
    }
  })
}

Keywords

hardware wallet

FAQs

Package last updated on 22 Jan 2020

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