New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

okj-fmts

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

okj-fmts

A TypeScript Wrapper for the Fedimint HTTP Client

  • 0.2.25
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Fedimint SDK in Typescript

This is a TypeScript client that consumes the Fedimint Http Client, communicating with it via HTTP and a password. It's a hacky prototype, but it works until we can get a proper TS client for Fedimint. All of the federation handling code happens in the fedimint-http-client, this just exposes a simple API for interacting with the client from TypeScript (will be mirrored in Python and Go).

Usage

import dotenv from "dotenv";
import { FedimintClientBuilder } from "fedimint-ts";

dotenv.config();

const baseUrl = process.env.BASE_URL || "http://localhost:3000";
const password = process.env.PASSWORD || "password";
const builder = new FedimintClientBuilder();
builder.setBaseUrl(baseUrl).setPassword(password);

// If you pass in an invite code, it will be set as the default federation
if (process.env.INVITE_CODE) {
  builder.setInviteCode(process.env.INVITE_CODE);
}

// The FedimintClient has a default federationId set that it'll call any module methods on
const fedimintClient = await builder.build();

// You can update the federationId to call methods on a different federation
const { federation_ids } = await fedimintClient.federationIds();
await fedimintClient.setDefaultFederationId(federation_ids[0]);

// Any methods that call on a specific federation can optionally take a federationId as the last argument
// If no federationId is passed, the default federationId is used
const _ = await fedimintClient.listOperations({ limit: 10 }, federation_ids[1]);

// Admin methods give summaries by federation
fedimintClient.info().then((response) => {
  console.log("Current Total Msats Ecash: ", response.total_amount_msat);
});

// All module methods are called on the default federationId if you don't pass in a federationId
const { operation_id, invoice } = await fedimintClient.ln.createInvoice({
  amount_msat: 10000,
  description: "test",
});

console.log("Created 10 sat Invoice: ", invoice);

console.log("Waiting for payment...");

fedimintClient.ln.awaitInvoice({ operation_id }).then((response) => {
  console.log("Payment Received!");
  console.log("New Total Msats Ecash: ", response.total_amount_msat);
});

Development

Install dependencies with bun install or npm install.

Follow these steps to setup a fedimint-clientd server and then you're ready to run the typescript client. fedimint-ts will use the same base url and password as the fedimint-clientd:

BASE_URL = 'http://localhost:5000'
PASSWORD = 'password'

Then run your code that follows the pattern of tests/info-example.ts.

bun run tests/info-example.ts

FAQs

Package last updated on 24 Apr 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc