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

@fleet-sdk/core

v0.7.0

Published

Fleet SDK core library

Downloads

611

Readme

@fleet-sdk/core License npm

Easily write Ergo off-chain code with a lightweight and pure JS library.

  • 🪄 Easy to use
  • 🪶 Lightweight: ~15kB minified + gziped
  • 🦾 Powerful: easily create complex transactions with a fluent API
  • 🧪 100% code coverage
  • 🌲 Tree-shakeable

Basic Usage

Installation

npm install @fleet-sdk/core

Building a simple transaction

import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to(new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j"))
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();

Building a transaction with multiple outputs

To build a a transaction with multiple outputs you can simply pass an array of OutputBuilder as argument of to() method.

import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to([
    new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j"),
    new OutputBuilder(2000000n, "9fhJkRaSoPfzE9rA3e4ptK51xvyNsLKonYN1xje5LWaLukx7iX2")
  ])
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();

Sending tokens

import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to(
    new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j").addTokens([
      { tokenId: "0cd8c9f416e5b1ca9f986a7f10a84191dfb85941619e49e53c0dc30ebf83324b", amount: 100n },
      { tokenId: "36aba4b4a97b65be491cf9f5ca57b5408b0da8d0194f30ec8330d1e8946161c1", amount: 429n }
    ])
  )
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();

Minting tokens

import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to(
    new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j").mintToken({
      name: "TestToken",
      amount: 21000000n,
      decimals: 4,
      description: "Just a test token"
    })
  )
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();

Burning tokens

import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .burnTokens([
    { tokenId: "0cd8c9f416e5b1ca9f986a7f10a84191dfb85941619e49e53c0dc30ebf83324b", amount: 100n },
    { tokenId: "36aba4b4a97b65be491cf9f5ca57b5408b0da8d0194f30ec8330d1e8946161c1", amount: 429n }
  ])
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .payMinFee()
  .build();

Ensuring input inclusion

You can use configureSelector method to ensure one or more inputs to be included in the transaction. Useful when working with contracts.

import { OutputBuilder, TransactionBuilder } from "@fleet-sdk/core";

const boxId = "e56847ed19b3dc6b72828fcfb992fdf7310828cf291221269b7ffc72fd66706e";
const unsignedTransaction = new TransactionBuilder(creationHeight)
  .from(inputs)
  .to(new OutputBuilder(1000000n, "9gNvAv97W71Wm33GoXgSQBFJxinFubKvE6wh2dEhFTSgYEe783j"))
  .sendChangeTo("9i2bQmRpCPLmDdVgBNyeAy7dDXqBQfjvcxVVt5YMzbDud6AvJS8")
  .configureSelector((selector) => selector.ensureInclusion((input) => input.boxId === boxId))
  .payMinFee()
  .build();