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

kofo-wallet

v1.2.5

Published

Kofo network supports blockchain wallet, which provides signature and private key management

Downloads

70

Readme

kofo wallet

Kofo network supports blockchain wallet, which provides signature and private key and mnemonic HDWallet management.Currently supporting BTC/USDT ETH/ERC20 HPB EOS BOS MEETONE BNB TRON chain and currency. This wallet does not have any communication with the full nodes of each chain. It is an offline wallet and only provides the rawTransaction signature returned by the gateway of KOFO network. High safety.

Note: TRON wallet does not support transaction signatures

Install and import

>$ npm i kofo-wallet --save
const Wallet = require('kofo-wallet');
or
import Wallet from 'kofo-wallet';

Include

  • Html script tag
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
</head>
<body>
<script src="https://atomic.kofo.io/kofo/kofowallet.js"></script>
<div>
   <!--Useage
   KofoWallet.createWallet(...)
   KofoWallet is a global object
   -->
</div>
</body>
</html>

Test

npm test

API

Wallet.supportsChain

Print the current wallet support chain

return String

Wallet.supportsChain
//return 'kofo wallet supports chain:< BTC ETH EOS MEETONE BOS HPB BNB>'

Wallet.createWallets(network, walletType)

Create all support chain wallets at once

params:

  • network [Optional] BTC/HPB/BNB network only, default "livenet"
  • walletType [Optional] BTC network only,default "P2PKH", supports P2PKH and P2SH. More info

returns {MnemonicWallets}

//btc wallet type 'P2PKH'
let wallets = Wallet.createWallets();
wallets.BTC.export()
wallets.ETH.export()
wallets.EOS.export()

//btc wallet type 'P2SH'
wallets = Wallet.createWallets('livenet', 'P2SH');
wallets.BTC.export()
wallets.ETH.export()
wallets.EOS.export()]

Wallet.createWallet(options)

Specify blockchain to create an HDWallet using mnemonic

options:

  • chain Chain name e.g ETH
  • currency Currency name e.g ETH
  • network [Optional] BTC/HPB/BNB network only, default "livenet"
  • language [Optional] Mnemonic language,default "en" english, supports [ENGLISH 'en', SPANISH 'es', JAPANESE 'ja', CHINESE 'zh', FRENCH 'fr', ITALIAN 'it']
  • walletType [Optional] BTC network only,default "P2PKH", supports P2PKH and P2SH. More info
  • path [Optional] Mnemonic derive path, each chain has a different path and default path value. More info

returns {MnemonicWallet}

//create eth wallet
let wallet = Wallet.createWallet({chain: 'ETH', currency: 'ETH'});
wallet.export()

//create btc wallet(P2PKH)
wallet = Wallet.createWallet({chain: 'BTC', currency: 'BTC'});
wallet.export()

//create btc wallet(P2SH)
wallet = Wallet.createWallet({chain: 'BTC', currency: 'BTC', walletType: 'P2SH'});
wallet.export()

Wallet.importMnemonicWallet(options)

Import mnemonic word HDWallet

options:

  • chain Chain name e.g ETH
  • currency: Currency name e.g ETH
  • mnemonic: The mnemonic string
  • language: [Optional] Mnemonic language,default "en" english,
  • network: [Optional] BTC/HPB/BNB network only, default "livenet"
  • walletType: [Optional] BTC network only,default "P2PKH", supports "P2PKH" and "P2SH". More info
  • path: [Optional] Mnemonic derive path. More info

returns {MnemonicWallet}

const mnemonic = 'side evidence harbor proof soft december bind example immense give cancel oven';
//import eth mnemonic hd wallet
let wallet = Wallet.importMnemonicWallet({chain: 'ETH', currency: 'ETH', mnemonic: mnemonic});
wallet.export()

//import btc mnemonic hd wallet(P2PKH)
wallet = Wallet.importMnemonicWallet({chain: 'BTC', currency: 'BTC', mnemonic:mnemonic});
wallet.export()

//create btc mnemonic hd wallet(P2SH)
wallet = Wallet.importMnemonicWallet({chain: 'BTC', currency: 'BTC',mnemonic: mnemonic, walletType: 'P2SH'});
wallet.export()

Wallet.importPrivateKey(options)

Import the wallet with the private key

options:

  • chain Chain name e.g ETH
  • currency: Currency name e.g ETH
  • privateKey: Wallet private key string
  • network: [Optional] BTC/HPB/BNB network only, default is "livenet".
  • walletType: [Optional] BTC network only,default "P2PKH", supports "P2PKH" and "P2SH". More info

returns {PrivateWallet}

//Import ETH private wallet
let wallet = Wallet.importPrivateWallet({chain:'ETH', currency:'ETH', privateKey:'07FED02BDB20EFE5297445472E2AD0647C9E288A5E28A4E0C7C18CEEFC09B470'});

//sign eth rawTransaction
wallet.sign('rawTransaction');

//export eth wallet info
wallet.export();

//Import BTC private wallet(P2SH)
wallet = Wallet.importPrivateWallet({chain: 'BTC', currency: 'BTC', privateKey:'L4djGpF8XrBoNQKitkT4S398Q8NijEzcdWayGPCS4hXnMDMTfbk2', walletType:'P2SH');
wallet.export()

//Import BTC private wallet(P2PKH)
wallet = Wallet.importPrivateWallet({chain: 'BTC', currency: 'BTC', privateKey:'L4djGpF8XrBoNQKitkT4S398Q8NijEzcdWayGPCS4hXnMDMTfbk2'});
wallet.export()

//sign btc rawTransaction
wallet.sign(rawTransaction);

async Wallet.importKeyStoreWallet(options)

Import the keystore encrypted file wallet, currently only ETH and HPB and BNB are supported

options:

  • chain Chain name e.g ETH
  • currency: Currency name e.g ETH
  • keystore: Keystore JSON
  • password: Keystore passphrase
  • network: [Optional] HPB/BNB network only, default is "livenet".

returns {Promise<PrivateWallet || MnemonicWallet>}

let wallet = Wallet.createWallet({chain: 'ETH', currency: 'ETH'});
let keystore = await wallet.exportKeyStore('pwd');
wallet = await Wallet.importKeyStoreWallet({
    chain: 'ETH',
    currency: 'ETH',
    keystore: keystore,
    password: 'pwd'
});
wallet.export()

Wallet.publicToAddress(options)

Takes public key hex-encoded string and returns the corresponding address

options:

  • chain Chain name e.g ETH
  • currency: Currency name e.g ETH
  • publicKey: Public key string
  • network: [Optional] BTC/BNB network only, default "livenet"
  • walletType: [Optional] BTC network only,default "P2PKH", supports "P2PKH" and "P2SH". More info

returns {address}

//ETH public key to address
let wallet = Wallet.createWallet({chain: 'ETH', currency: 'ETH'});
let publicKey = wallet.export().publicKey;
Wallet.publicToAddress({chain: 'ETH', currency: 'ETH', publicKey: publicKey})

//BTC P2PKH
wallet = Wallet.createWallet({chain: 'BTC', currency: 'BTC'});
publicKey = wallet.export().publicKey;
Wallet.publicToAddress({chain: 'BTC', currency: 'BTC', publicKey: publicKey})

//BTC P2SH
wallet = Wallet.createWallet({chain: 'BTC', currency: 'BTC', walletType: 'P2SH'});
publicKey = wallet.export().publicKey;
Wallet.publicToAddress({chain: 'BTC', currency: 'BTC', publicKey: publicKey, walletType: 'P2SH'})