Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@lawallet/sdk

Package Overview
Dependencies
Maintainers
5
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lawallet/sdk

LaWallet software dev kit

latest
Source
npmnpm
Version
0.1.46
Version published
Maintainers
5
Created
Source

@lawallet/sdk

SDK for LaWallet

Installation

pnpm add @lawallet/sdk

Usage examples

Fetch

import { Wallet, createSigner } from '@lawallet/sdk';

const Alice = new Wallet({ signer: createSigner("ALICE_SECRET_KEY") });
const Bob = new Wallet({ signer: createSigner("BOB_SECRET_KEY") });

Alice.fetch().then(({ lnurlpData, nostr }) => {
  // returns lnurlpData -> /.well-known/lnurlp/<user> response
  console.log('lnurlpData: ', lnurlpData);

  // returns nostr profile
  console.log('Nostr Profile: ', nostr);
});

getBalance

// Returns BTC balance in millisatoshis
Alice.getBalance('BTC').then((bal) => {
  console.log(`Account BTC Balance: ${bal} milisatoshis ~ ${(bal / 100000000).toFixed(8)} BTC`);
});

getTransactions

// Returns all transactions
Alice.getTransactions().then((transactions) => {
  console.log('Total account transactions: ', transactions.length);
});

Cards

Alice.addCard('CARD_NONCE');

Alice.getCards().then(async (cards) => {
  if (cards.length) {
    // Get first card
    let firstCard = cards[0];

    // Pause first card
    await firstCard.disable();

    // Add card limit -> 1000 satoshis every 12 hours
    await firstCard.addLimit({
      tokenId: 'BTC',
      limitType: 'hours',
      limitTime: 12,
      limitAmount: 1000000,
    });

    // Set card metadata (name, description)
    await firstCard.setMetadata({ name: 'card name', description: 'card description' });

    // Prepare the event to transfer the card
    const transferEvent = await firstCard.createTransferEvent();

    // Claim card with another account
    await Bob.claimCardTransfer(transferEvent);
  }
});

Payments

Alice.generateInvoice({ milisatoshis: 1000 }).then((invoice) => {
  // Generate payment request of this wallet
  console.log(invoice.pr);
});

Alice.createZap({ milisatoshis: 1000, receiverPubkey: Bob.pubkey }).then((invoice) => {
  // Generate zap request -> returns payment request of zap request
  const { pr: paymentRequest } = invoice;

  // Pay invoice
  Alice.payInvoice({
    paymentRequest,
    onSuccess: () => {
      console.log('Invoice paid successfully');
    },
  });
});

// Send transaction
Alice.sendTransaction({
  tokenId: 'BTC',
  receiver: 'cuervo@lawallet.ar',
  amount: 1000,
  comment: 'Hello!',
  onSuccess: () => {
    console.log('Transaction successfully sent');
  },
  onError: () => {
    console.log('An error occurred with the transaction');
  },
});

// Send internal transaction
Alice.sendInternalTransaction({
  tokenId: 'BTC',
  receiver: 'USER_HEX_PUBKEY',
  amount: 1000,
  comment: 'Hello!',
  onSuccess: () => {
    console.log('Transaction successfully sent');
  },
  onError: () => {
    console.log('An error occurred with the transaction');
  },
});

To - do

  • Project startup (Linters, Typescript, Dependencies)

  • Federation

  • Identity

    • Pubkey info
    • Lightning Info
    • Nostr Profile
  • Card

    • info (design, name, description)
    • limits
    • enable/disable
    • setMetadata
    • addLimit
    • restartLimits
    • replaceLimits
    • createTransferEvent
  • Wallet

    • Signer + Identity
    • Wallet Information
      • getBalance
      • getTransactions
      • getCards
    • signEvent
    • createZap
    • createInvoice
    • sendTransaction
      • send internal / lud16 / lnurl transfer
      • onSuccess()
      • onError()
    • payInvoice
    • claimCardTransfer
    • addCard / activateCard
    • registerHandle (request + payment + claim)
  • Tests coverage

    • Federation
    • Identity
    • Wallet

FAQs

Package last updated on 27 May 2025

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