You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

bsv-wallet-95

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

bsv-wallet-95

A Bitcoin SV Wallet Library

1.1.9
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

BsvWallet ⚡🔑

A simple Bitcoin SV wallet library

  • can work offline ✅
  • enable peer to peer transactions ✅
  • follow the whitepaper ✅
  • browser friendly ✅
  • autocomplete in js and ts files ✅
  • HD Private Keys at 0 technical cost ✅
  • ❤️ easy to use ❤️

How to install

npm i bsv-wallet

How to import

Typescript

const { Wallet } from "bsv-wallet"

Javascript

const { Wallet } = require("bsv-wallet");

How to use

Create or Import a wallet

Import with a mnemonic

const myMnemonic = "awkward will execute giant ...";

const wallet = new Wallet({ key: myMnemonic });

Import with a seed string

const seed = "Kwn6yDoKobVjH2dqa9UZ4c5yXfUQQo6PxdQ...";

const walet = new Wallet({ key: seed, keyFormat: "string" });

Create a new Wallet and get the mnemonic

const wallet = new Wallet();
const myNewWalletMnemonic = wallet.getMnemonic();

// to save it into a file
require("fs").writeFileSync("private.key", myNewWalletMnemonic);
// or into localStorage if your are into a web browser
localStorage.setItem("key", myNewWalletMnemonic);

Get your balance

const balanceInSatoshis = wallet.getBalance();

console.log({ balanceInSatoshis });

Sign a tx for your friend

const friendAdr = "";

const txHex = await wallet.signTx({
  to: friendAdr,
  amount: 5000,
});

Broadcast it to the blockchain

const txHex = "...";

wallet.broadcast(txHex); // return a promise to check if it worked or not

Exemple: Bob sending money to Alice

// * we import two wallet
const walletBob = new Wallet(key: "bob private key");
const walletAlice = new Wallet(key: "alice private key");

// * get the Alice address
const adrAlice = await walletAlice.getAddress();

// * sign a tx for Alice with the bob wallet
const txForAlice = await walletBob.signTx({
  to: adrAlice,
  amount: 1234
});

// right now the tx is signed but not in the bsv blockchain
// ( like a signed check but not delivered to the bank)
// to do so you will have to broadcast it

// either with the simpler classical model
walletBob.broadcast(txForAlice)

// or (optionnal) with the peer to peer model were it is to Alice that is in charge to get back her fund
walletAlice.broadcast(txForAlice)

Dev note

There i no other documentation at this time but the autocomplete will mostly tell you how to use it

If you wish to contribute or encounter any issue You can contact me on my discord @Kysan#8315

Keywords

javascript

FAQs

Package last updated on 01 Jan 2023

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