Giter Site home page Giter Site logo

bsvwallet's Introduction

BsvWallet โšก๐Ÿ”‘

A simple JavaScript library for Bitcoin SV (BSV)

  • enable peer to peer transactions โœ…
  • Typescript and JavaScript autocomplete โœ…
  • browser & node friendly โœ…
  • โค๏ธ easy to use โค๏ธ

Current features:

  • create your wallet (new private key)

  • import your wallet (from a private key)

  • get your wallet address

  • sign a transactions

  • broadcast a transactions

  • send money (sign & then broadcast your tx)

  • get your wallet balance

  • get your wallet tx history

  • read blockchain data

  • work offline (P2PWallet)

    Next features:

  • Stas token (easy NFT minting)

  • Hierarchical Deterministic (HD) Wallet at 0 technical cost

  • More stable RPC than Whatsonchain

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

Import a wallet

const wallet = new Wallet({ key: "awkward will execute giant ..." });

Create a new Wallet and get the mnemonic

const wallet = new Wallet(); // just pass nothing
const key = wallet.getPrivateKey(); // ->  "awkward will angle wide ... canoe demise execute"

Get your balance

const balanceInSatoshis = await wallet.getBalance();

console.log({ balanceInSatoshis });

Get your address

const myAddress = await wallet.getAddress();

console.log({ myAddress });

Sign a tx for your friend

const friendAdr = "oKobVjH2dqa9U...";

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

Broadcast it to the blockchain

const txHex = "...";

const txId = await wallet.broadcast(txHex);
// return the tx id if it worked else it will throw an error

Exemple: Bob sending money to Alice

const walletBob = new Wallet(key: "bob private key");

const transactionId = await walletBob.sendMoney({
  to: "alice address",
  amount: 1234
});

Dev note

If you wish to contribute or encounter any issues please contact me on discord @Kysan#8315 or by email at [email protected]

bsvwallet's People

Contributors

kysan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.