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

@getsafle/bsc-wallet-controller

v1.0.0

Published

This repository contains `BSCHdKeyring` class to create **Binance smart chain wallet** from **Safle Vault**.

Downloads

2

Readme

bsc-wallet-controller

This repository contains BSCHdKeyring class to create Binance smart chain wallet from Safle Vault.

Usecase

We will be using BSCHdKeyring class to initialize the wallet and then utilize the provided functions to perform the required tasks. The class initialization is done in the following way.

const bscWallet = new BSCHdKeyring(`mnemonic`)

mnemonic is the BIP-39 key phrase to generate the wallet.

Once we initialize the class, we can utilize the provided functions.

The wallet have the following functions:

generateWallet()

This function is used to generate the BSC wallet and set the 0th address as the default address. parameters: - returns: {address: string} // wallet address

exportPrivateKey()

This function is used to export the private key for the generated address. parameters: - returns: {privateKey: string} // address private key

signTransaction(transaction: TransactionObj , connectionUrl: string )

This function is used to sign a transaction off-chain and then send it to the network. Transactions are of 4 types:

  1. BSC transfer: Trasaction to transfer BSC from one wallet/address to another.The transaction object is of the following type:
TransactionObj: {
    data: {
        to, // destination address
        amount, // amount in wei
    },
    txnType: NATIVE_TRANSFER // type constant
}
  1. Contract transactions: Transaction to call any smart contract function.The transaction object is of the following type:
TransactionObj: {
    data: {
        to, // destination smart contract address
        amount, // amount in wei
        data, // hex string of the encoded data
    },
    txnType: CONTRACT_TRANSACTION // type constant
}

parameters:

name: transaction,
type: TransactionObj, // refer to the above 2 trancationObj types.

name: connectionUrl, // BTC network {TESTNET | MAINNET}
type: string,
default: MAINNET (undefined)
optional

returns: {signedTransaction: string} signed raw transaction

signMessage(message: string )

This function is used to sign a message. parameters:

name: message
type: string

returns: {signedMessage: string} // signed message hex string

getAccounts()

This function is used to get the wallet address. parameters: - returns: {address: string} // wallet address

sendTransaction(rawTransaction: string , connectionUrl: string)

This function is used send the signed transaction onto the chain. parameters:

name: rawTransaction, // signed raw transaction (got from signedTransaction())
type: string

name: connectionUrl, // BTC network {TESTNET | MAINNET}
type: string,
default: MAINNET (undefined)
optional

returns: {transactionDetails : string} // transaction hash

getFee(transaction: TransactionObj , connectionUrl: string)

This function is returns the fees in wei which will be used for the passed transaction.

parameters:

name: transaction,
type: TransactionObj, // refer to the 2 trancationObj types provided in signTransaction.

name: connectionUrl, // BTC network {TESTNET | MAINNET}
type: string,
default: MAINNET (undefined)
optional

returns: {transactionFees: integer} // transaction fees

getBalance(connectionUrl: string)

This function is returns the account balance in wei.

parameters:

name: connectionUrl, // BTC network {TESTNET | MAINNET}
type: string,
default: MAINNET (undefined)
optional

returns: {balance: integer} // transaction fees