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

simple-bch-slp

v1.0.3

Published

Simple SLP is a package written in nodejs to deal with bitcoin-cash slp and bch transaction

Downloads

9

Readme

Simple BCH SLP

Simple SLP is a package written in nodejs to deal with bitcoin-cash slp and bch transaction

this is my first project. and i dont have any experience in repo and clean coding. so you will found some mess here

but i am willing to clean it in the next commit

i will try my best to make this updated

btw watch bch / slp transaction is not available yet i will add it in next time if i have time😅

also the change address is send to the same address where it came from i havent implemented the change address because i dont know gow they works😅 for someone who knows it your all welcome to push commits😅

Installation

npm install simple-bch-slp

Functions

Initializing

Arguments

  • grpcUrl: string Default:
    • method grpc : bchd.fountainhead.cash:443
    • method grpc testnet : bchd-testnet.greyh.at:18335
    • method rest | method rest testnet : (undefined we cant provide server for it :( but its oupensource)
  • method: "grpc" | "rest" Default: grpc
  • slpDbUrl: string Default:
    • testnet: https://slpdb-testnet.fountainhead.cash
    • mainnet: https://slpdb.fountainhead.cash
  • slpSocket: string Default: https://bitsocket.bch.sx (not implemented)
  • bchSocket: string Default: https://slpstream.fountainhead.cash (not implemented)
  • testnet: boolean Default: false
import SIMPLESLP from "simple-bch-slp";
const Testnet = new SIMPLESLP({ testnet: true });
async function main() {
    //code here...
}
main();

Wallet

NOTE

  • the network depends on what you select in initialize section
  • the if block is required

Create new wallet

-- you cannot use this to create transaction after you create you need to import it first 😅

Arguments

  • derivation path: string Default: m/44'/0'/0'/0/0
const wallet1 = await Testnet.create("m/44'/245'/0'/0/0");
if ("error" in wallet1) return console.log(wallet1);
console.log(wallet1);
// {
//     seed: 'foster apology airport sadness rain rice cluster say spare light collect rural',
//     derivationPath: "m/44'/245'/0'/0/0",
//     wif: 'cSPrirsppgLbvcnGrtxYnnyuE4cPJXoESZJpeUJBqkzz6uH67NKj',
//     bch: 'bchtest:qqutew4e5l9gpxrckxn7g64xst0cv7m6yss23j5t6a',
//     slp: 'slptest:qqutew4e5l9gpxrckxn7g64xst0cv7m6yst7kfwugq',
//     legacy: 'mkgxDwkaJusXTvadSD4iieXnX3P9JQtYyv'
// }

Import from wif

Arguments

  • wif: string required
const wallet1 = await Testnet.fromWIF(
    "cSPrirsppgLbvcnGrtxYnnyuE4cPJXoESZJpeUJBqkzz6uH67NKj"
);
if ("error" in wallet1) return console.log(wallet1);
console.log(wallet1.Address.toCash());
// bchtest:qqutew4e5l9gpxrckxn7g64xst0cv7m6yss23j5t6a

Import from Seed phrases

Arguments

  • seed: string required
  • derivation path : string Default m/44’/0’/0’/0/0
const wallet1 = await Testnet.fromSeed(
    "foster apology airport sadness rain rice cluster say spare light collect rural",
    "m/44'/245'/0'/0/0"
);
if ("error" in wallet1) return console.log(wallet1);
console.log(wallet1.Address.toCash());
// bchtest:qqutew4e5l9gpxrckxn7g64xst0cv7m6yss23j5t6a

Address

  • Note: you need to use the variable from the import wif / seed
  • Arguments
    -- qrcode: boolean Default false -- amount: number Default 0
  • To Bitcoincash Address

console.log(wallet1.Address.toCash());
// bchtest:qqutew4e5l9gpxrckxn7g64xst0cv7m6yss23j5t6a
  • To SLP Address

console.log(wallet1.Address.toSlp());
// slptest:qqutew4e5l9gpxrckxn7g64xst0cv7m6yst7kfwugq
  • To Legacy Address

console.log(wallet1.Address.toLegacy());
// mkgxDwkaJusXTvadSD4iieXnX3P9JQtYyv

BCH

  • balance

    • Argument: -- format: string: "satoshi" | "bch" | "bits" Default satoshi
console.log(await wallet1.BCH.balance("bch"));
// 0.0001
  • max amount to send

    • Argument: -- format: string: "satoshi" | "bch" | "bits" Default satoshi
console.log(await wallet1.BCH.maxAmount("bch"));
// 0.0001	
  • send

    • Argument:

      -- address: string: required

      -- amount: number: required - in bch form, minimum 0.00000546 bch

      -- get fee: boolean : Default false

    console.log(
        await wallet1.BCH.send(
            "bchtest:qqqg3m66m5s2zvvwk6y4tsuh0phta8qtrcv8se9uqk",
            546
        )
    );
	// {
    //     error: false,
    //     txid: '8c555414f195799dd0977a351af3632d40e7d9d1594abe73f1151e09d9982d7f',
    //     message: ''
    // }
  • Send All

    • Argument:

      -- address: string: required

      -- get fee: boolean : Default false

console.log(
        await wallet1.BCH.sendAll(
            "bchtest:qqqg3m66m5s2zvvwk6y4tsuh0phta8qtrcv8se9uqk"
        )
    );
	// {
    //     error: false,
    //     txid: '0209308c7366ababdec0661d0afe8b674fe4c4d2afaf0f639b06851d5fdf0912',
    //     message: ''
    // }

SLP

  • Balance

    • Argument:

      -- tokenId: string[] | "all": default "all"

console.log(await wallet1.SLP.balance());
// [
    //     {
    //       id: '132731d90ac4c88a79d55eae2ad92709b415de886329e958cf35fdd81ba34c15',
    //       amount: '1000',
    //       parentTokenId: undefined,
    //       name: 'Mainnet coin',
    //       symbol: 'MNC',
    //       documentUri: 'https://mainnet.cash',
    //       documentHash: '0000000000000000000000000000000000000000000000000000000000000000'
    //     }
    // ]
  • Parent Genesis

    • Argument: {

      -- symbol: string: required

      -- name: string: required

      -- documentUri: string: required

      -- documentHash: string: required

      -- amount: number: required,,

      -- getFee: boolean: Default false

      -- fixedSupply: boolean Default false

}

  console.log(
        await wallet1.SLP.parentGenesis({
            symbol: "SBS",
            name: "simple-bch-slp",
            documentUri: "",
            documentHash: "",
            amount: 100000,
        })
    );
	//{
  //error: false,
  //txid: '21ff93cf20d57579db47bb6598ff38732f495e0cbae51b016a5cb4f58e21fb29',
  //message: ''
//}
  • Child Genesis

    • Argument: {

      -- parentTokenId: string: required

      -- name: string: required

      -- symbol: string: required

      -- documentUri: string: required

      -- documentHash: string: required

      -- getFee: boolean Default false

      -- autoSplit: boolean Default false

}

    console.log(
        await wallet1.SLP.childGenesis({
            parentTokenId:
                "21ff93cf20d57579db47bb6598ff38732f495e0cbae51b016a5cb4f58e21fb29",
            name: "child",
            symbol: "SBS",
            documentUri: "",
            documentHash: "",
            autoSplit: true,
        })
    );
	// {
    //     splitTx: {
    //       error: false,
    //       txid: 'f28286eea3487563704407000886a8f8938afbf5ddfdfd5052c94fc7e903f6af',
    //       message: ''
    //     },
    //     mintTx: {
    //       error: false,
    //       txid: 'e387b421b2e1496e104c447a0ff7499480ada4a92f48c6cebb27bf8029bd0257',
    //       message: ''
    //     }
    // }
  • Add Supply

    • NOTE: you can only use this if mint baton is in your address

    • Argument:

      -- parentTokenId: string: required

      -- amount: number: required

      -- getFee: boolean Default false

console.log(
        await wallet1.SLP.addSupply(
            "21ff93cf20d57579db47bb6598ff38732f495e0cbae51b016a5cb4f58e21fb29",
            1000
        )
    );
	// {
    //     error: false,
    //     txid: '7ca530d6582214192a2e5daa5851f3d51e7acac8eb19b807fa4dbb4454b51b8b',
    //     message: ''
    // }
  • Destroy Supply

    • NOTE : split utxo tx will add to result if you dont have splited utxo. i add 1000 supply before so i have splited already. thats why the response are the burnTx only

    • Argument:

      -- tokenId: string: required

      -- amount: number | "all": required

      -- getFee: boolean Default false

    console.log(
        await wallet1.SLP.burnGroup(
            "21ff93cf20d57579db47bb6598ff38732f495e0cbae51b016a5cb4f58e21fb29",
            1000
        )
    );
	// {
    //     burnTx: {
    //       error: false,
    //       txid: '62a2d9beef15f6ff75831ec7e94ea536b7e3cccc1d43700e10d4acfb5b16790c',
    //       message: ''
    //     }
    // }
  • Destroy Mint Baton

    • if you destroy mint baton you will not able to add supply

    • Argument:

      -- tokenId: string: required

    console.log(
        await wallet1.SLP.destroyMintBaton(
            "21ff93cf20d57579db47bb6598ff38732f495e0cbae51b016a5cb4f58e21fb29"
        )
    );
    // {
    //     error: false,
    //     txid: '815250543e9214be7e6266e1ecde88b096929814daf4252c6d0d30a7aca62352',
    //     message: ''
    // }
  • Split Utxos

    • this function is called in destroy supply the splitTx one

    • Argument:

      -- tokenId: string: required

console.log(
        await wallet1.SLP.splitUtxo(
            "21ff93cf20d57579db47bb6598ff38732f495e0cbae51b016a5cb4f58e21fb29",
            1000
        )
    );
	// {
    //     error: false,
    //     txid: '06a4a3bb513960f82fc4c78374a58e2e80672d3852824a214bf64fca43cb244f',
    //     message: ''
    // }
  • Send

    • Argument:

      -- address: string: required: the simpleledger:... address

      -- tokenId: string: required

      -- amount: number: Default 1

      -- getFee: boolean: Default false

    console.log(
        await wallet1.SLP.send(
            "slptest:qqqg3m66m5s2zvvwk6y4tsuh0phta8qtrchnhzltjt",
            "21ff93cf20d57579db47bb6598ff38732f495e0cbae51b016a5cb4f58e21fb29",
            100
        )
    );
	// {
    //     error: false,
    //     txid: 'edbc46c4dc43f8366076860010c5bba11153c0b3ca7dc99de5c468730a1475b3',
    //     message: ''
    // }
  • To WIF

    console.log(await wallet1.toWIF());
	//cSPrirsppgLbvcnGrtxYnnyuE4cPJXoESZJpeUJBqkzz6uH67NKj

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

copy paste 😆

License

MIT

Donations😄

bch.md.jpg bitcoincash:qryphmuqxjlfjna4cv45rddmf8sn6qm6kylrsh8955