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

@secux/app-eth

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@secux/app-eth

SecuX Hardware Wallet ETH API

  • 2.1.2
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by200%
Maintainers
2
Weekly downloads
 
Created
Source

@secux/app-eth

SecuX Hardware Wallet ETH API

Usage

import { SecuxETH } from "@secux/app-eth";

First, create instance of ITransport

  • Web Usb
  • Web Bluetooth
  • React Native Bluetooth

Examples

  1. Get address derived by given BIP44 path
const address = await SecuxETH.getAddress(device, "m/44'/60'/0'/0/0");
  1. Sign legacy transaction (EIP-155)
const { raw_tx, signature } = await SecuxETH.signTransaction(
    device,
    "m/44'/60'/0'/0/0",
    {
        nonce: 0,
        to: "0xD080156885651fADbD6df14145051b934660a748",
        value: 1e10,
        chainId: 1,
        gasPrice: 1e6,
        gasLimit: 25000
    }
);
  1. Sign EIP-1559 transaction
const { raw_tx, signature } = await SecuxETH.signTransaction(
    device,
    "m/44'/60'/0'/0/0",
    {
        nonce: 0,
        to: "0xD080156885651fADbD6df14145051b934660a748",
        value: 1e10,
        chainId: 1,
        maxPriorityFeePerGas: 1e4,
        maxFeePerGas: 1e6,
        gasLimit: 25000
    }
);
  1. Sign transaction with Smart Contract (ERC-20)
const { raw_tx, signature } = await SecuxETH.signTransaction(
    device,
    "m/44'/60'/0'/0/0",
    {
        nonce: 0,
        to: "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
        value: 0,
        data: "0xa9059cbb000000000000000000000000d080156885651fadbd6df14145051b934660a7410000000000000000000000000000000000000000000000000000000000989680",
        chainId: 1,
        gasPrice: 1e6,
        gasLimit: 25000
    }
);


// transfer token easy use
const { raw_tx, signature } = await SecuxETH.signTransaction(
    device,
    "m/44'/60'/0'/0/0",
    {
        nonce: 0,
        to: "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
        value: 0,
        data: {
            toAddress: "0xD080156885651fADbD6df14145051b934660a748",
            amount: `0x${1e18.toString(16)}`
        },
        chainId: 1,
        gasPrice: 1e6,
        gasLimit: 25000
    }
);
  1. Sign Message transaction
const { raw_tx, signature } = await SecuxETH.signMessage(device, "m/44'/60'/0'/0/0", msg);
  1. Sign TypedMessage transaction
const { raw_tx, signature } = await SecuxETH.signTypedMessage(device, "m/44'/60'/0'/0/0", msg);
  1. Sign transaction with WalletConnect
const { raw_tx, signature } = await SecuxETH.signWalletConnectTransaction(
    device,
    "m/44'/60'/0'/0/0",
    {
        nonce: 0,
        to: "0xD080156885651fADbD6df14145051b934660a748",
        value: 0,
        data: "0x7ff36ab5000000000000000000000000000000000000000000000000302bf3f82d406d120000000000000000000000000000000000000000000000000000000000000080000000000000000000000000d080156885651fadbd6df14145051b934660a7480000000000000000000000000000000000000000000000000000000060b613630000000000000000000000000000000000000000000000000000000000000003000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c0000000000000000000000007130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56",
        chainId: 56,
        gasPrice: 1e6,
        gasLimit: 25000
    }
);

Note

  1. Value of chainId (same as EIP-155):
    • Ethereum Mainnet: 1
    • Binance Smart Chain Mainnet: 56
    • Polygon Network: 137
    • goto https://chainlist.org/ for your specific chain

API doc

SecuxETH

ETH package for SecuX device

Kind: global class


SecuxETH.getAddress(trans, path)string

Get EIP55 address derived by given BIP32 path

Kind: static method of SecuxETH
Returns: string - EIP55 address

ParamTypeDescription
transITransport
pathstringBIP32


SecuxETH.signTransaction(trans, path, content)object

Create transaction and Sign

Kind: static method of SecuxETH
Returns: object - signed
string - signed.raw_tx
Buffer - signed.signature

ParamTypeDescription
transITransport
pathstringBIP32
contenttxDetailtransaction content


SecuxETH.signMessage(trans, path, message, chainId)object

Create message type transaction and Sign

Kind: static method of SecuxETH
Returns: object - signed
string - signed.raw_tx
Buffer - signed.signature

ParamTypeDefaultDescription
transITransport
pathstringBIP32
messagestring
chainIdnumber11: ETH, 56: BSC


SecuxETH.signTypedData(trans, path, data, chainId)object

Create EIP712 transaction and Sign

Kind: static method of SecuxETH
Returns: object - signed
string - signed.raw_tx
Buffer - signed.signature

ParamTypeDefaultDescription
transITransport
pathstringBIP32
dataTypedDataEIP712
chainIdnumber11: ETH, 56: BSC


SecuxETH.signWalletConnectTransaction(trans, path, content)object

Create transaction and Sign using WalletConnect protocol

Kind: static method of SecuxETH
Returns: object - signed
string - signed.raw_tx
Buffer - signed.signature

ParamTypeDescription
transITransport
pathstringBIP32
contenttxDetailtransaction content

Keywords

FAQs

Package last updated on 27 Oct 2021

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