0.0.11 • Published 1 year ago

topether21-nosft-core v0.0.11

Weekly downloads
-
License
Public domain
Repository
github
Last release
1 year ago

nosft-core

Tools for developing Nosft clients

Installation

npm install nosft-core # or yarn add nosft-core

Usage

NodeJs & Browser

const nosftCore = require('nosft-core');

or
const { nosft } = require('nosft-core');

or

import { nosft } = require('nosft-core');

Initialize library

Defaults to mainnet config

const { nosft } = require('nosft-core');

(async () => {
    const inscriptions = await nosft.getAddressInscriptions({
        address: process.env.BTC_ADDRESS,
        offset: 0,
        limit: 2,
    });
    console.log(JSON.stringify(inscriptions, undefined, 4));
})();

Configure library

If you want to specify your custom configs, you can do so by:

const nosftCore = require('nosft-core');

(async () => {
    const { nosft } = nosftCore.configure({ nosftBaseUrl: 'http://localhost:3000/api', network: 'testnet' });
    const inscriptions = await nosft.getAddressInscriptions({
        address: process.env.BTC_ADDRESS,
        offset: 0,
        limit: 2,
    });

    console.log(JSON.stringify(inscriptions, undefined, 4));
})();

Getting inscriptions

const { nosft } = require('nosft-core');
const inscriptions = await nosft.getAddressInscriptions({
    address: process.env.BTC_ADDRESS,
    offset: 0,
    limit: 2,
});

Getting OnSale Ordinals

Server Side/Node

import 'websocket-polyfill'; // only for nodejs/server-side
import { NostrRelay } from 'nosft-core';

(async () => {
    const relay = new NostrRelay();
    relay.subscribeOrders({
        limit: 10,
        onOrder: (order) => {
            console.log('new order');
            console.log(order.id);
        },
        onEose: () => {
            console.log('eose');
        },
    });
})();

Developing

  1. Install just
  2. just -l

License

Public domain.