npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-wallet-core

v0.1.4

Published

A React Native wrapper around the Trust Wallet Core wallet library for Android and iOS

Downloads

8

Readme

react-native-wallet-core

A React Native wrapper around the Trust Wallet Core wallet library for Android and iOS.

For more information about the underlying library, please read the comprehensive documentation provided by Trust Wallet here.

Installation

npm install react-native-wallet-core

Currencies Supported

Currently the only currency supported with this wrapper is Ethereum. There will be more coming in the future.

Usage

import TrustWalletCore from "react-native-wallet-core";

// Create a new wallet
const { mnemonic, seed } = await TrustWalletCore.createWallet(128, "");

Full Documentation

createWallet(strength, passphrase)

Creates a new wallet.

  • strength number - Strength of the secret seed. Possible options are 128 or 256.
  • passphrase string (optional) - Used to scramble the seed
  • Returns
    • mnemonic string - the recovery phrase of the wallet
    • seed string - hex seed of the wallet. Can also be used to import.
const { mnemonic, seed } = await TrustWalletCore.createWallet(128, "");

importWalletFromMnemonic(mnemonic, passphrase)

Import a wallet from a mnemonic recovery phrase. This will also load the wallet into local memory so that it can be used for creating addresses and/or signing transactions.

  • mnemonic string - Recovery phrase
  • passphrase string (optional) - The passphrase used when creating the wallet (if applicable)
  • Returns
    • mnemonic string - the recovery phrase of the wallet
    • seed string - hex seed of the wallet. Can also be used to import.
const { mnemonic, seed } = await TrustWalletCore.importWalletFromMnemonic("ripple scissors kick mammal hire column oak again sun offer wealth tomorrow wagon turn fatal", "");

importWalletFromHexString(hexString, passphrase)

Import a wallet from a hexString seed. This will also load the wallet into local memory so that it can be used for creating addresses and/or signing transactions.

  • hexString string - The hex string seed
  • passphrase string (optional) - The passphrase used when creating the wallet (if applicable)
  • Returns
    • mnemonic string - the recovery phrase of the wallet
    • seed string - hex seed of the wallet. Can also be used to import.
const { mnemonic, seed } = await TrustWalletCore.importWalletFromHexString("<HEX_STRING>", "");

getAddressForCoin(coin)

Generate and retrieve the default address for a coin. The address is generated using the default derivation path of a coin.

  • coin string - The coin type
  • Returns
    • address string - The public key of the address
const address = await TrustWalletCore.getAddressForCoin("ethereum");

deriveAddressForCoin(coin, derivationPath)

Generate an address using a custom derivation path.

  • coin string - The coin type
  • derivationPath string - Derivation path to be used when generating the address
  • Returns
    • address string - The public key of the address
    • privateKey string - The private key of the address
const { address, privateKey } = await TrustWalletCore.deriveAddressForCoin("ethereum", "m/44'/60'/1'/0/0");

signTransactionForCoin(coin, input)

Generate and retrieve the default address for a coin. The address is generated using the default derivation path of a coin.

  • coin string - The coin type
  • input object
    • toAddress string - Destination of the funds (Public Key).
    • amount string - The amount to include in the transaction. Should be a hex string.
    • privateKeyDerivationPath string (optional) - Provide a derivation path if you want to use an address that is NOT the default address.
    • chainID string (optional) - Ethereum Network selector. Should be a hex string. (Default is 01)
    • gasPrice string (optional) - Should be a hex string. (Default is d693a400)
    • gasLimit string (optional) - Should be a hex string. (Default is 5208)
    • nonce string (optional) - The count of the number of outgoing transactions. Should be a hex string. (Default is 00)
  • Returns
    • r string
    • s string
    • v string
    • encoded string
    • hashValue string
const { r, s, v, encoded, hashValue } = await TrustWalletCore.signTransactionForCoin("ethereum", {
    chainID: "0x01",
    amount: "0x0348bca5a16000",
    nonce: "0x00",
    toAddress: "0xC37054b3b48C3317082E7ba872d7753D13da4986",
    privateKeyDerivationPath: "m/44'/60'/1'/0/0", // optional - otherwise default address is used
});

cleanup()

Cleanup any previously loaded wallet from local memory.

await TrustWalletCore.cleanup();

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT