React Hooks
createConfig

createConfig

Creates new Config object.

Import

import { createConfig } from '@lawallet/react';

Usage

Config.ts
import { createConfig, createSignerWithPrivateKey } from '@lawallet/react';
 
const signer = createSignerWithPrivateKey('5caa3cd87cf1ad069bcf...a7b6070a44ec7223877504c84');
 
export const config = createConfig({
  endpoints: {
    gateway: 'https://api.lawallet.ar',
    lightningDomain: 'https://lawallet.ar',
  },
  federationId: 'lawallet.ar',
  modulePubkeys: {
    card: '18f6a706091b421bd9db1ec964b4f934007fb6997c60e3c500fdaebe5f9f7b18',
    ledger: 'bd9b0b60d5cd2a9df282fc504e88334995e6fac8b148fa89e0f8c09e2a570a84',
    urlx: 'e17feb5f2cf83546bcf7fd9c8237b05275be958bd521543c2285ffc6c2d654b3',
  },
  relaysList: ['wss://relay.damus.io', 'wss://relay.lawallet.ar'],
  signer,
});

Parameters

endpoints

EndpointsConfigurationType

  • LaWallet Configurable Endpoints
import { createConfig } from '@lawallet/react';
 
export const config = createConfig({
  endpoints: {
    gateway: 'https://api.lawallet.ar',
    lightningDomain: 'https://lawallet.ar',
  },
});

federationId

String

  • Federation Settings
import { createConfig } from '@lawallet/react';
 
export const config = createConfig({
  federationId: 'lawallet.ar',
});

modulePubkeys

ModulePubkeysConfigType

  • Configuring the public keys of each backend module
import { createConfig } from '@lawallet/react';
 
export const config = createConfig({
  modulePubkeys: {
    card: '18f6a706091b421bd9db1ec964b4f934007fb6997c60e3c500fdaebe5f9f7b18',
    ledger: 'bd9b0b60d5cd2a9df282fc504e88334995e6fac8b148fa89e0f8c09e2a570a84',
    urlx: 'e17feb5f2cf83546bcf7fd9c8237b05275be958bd521543c2285ffc6c2d654b3',
  },
});

relaysList

String[]

  • List of relays you want to connect to
import { createConfig } from '@lawallet/react';
 
export const config = createConfig({
  relaysList: ['wss://relay.damus.io', 'wss://relay.lawallet.ar'],
});

storage

Storage | undefined

  • Storage used by the configuration. Persists state between sessions.
  • Defaults to createStorage({ storage: typeof window !== 'undefined' && window.localStorage ? window.localStorage : noopStorage }).
import { createConfig, createStorage } from '@lawallet/react';
 
export const config = createConfig({
  storage: createStorage({ storage: localStorage }),
});

signer

SignerTypes | undefined

  • Defines an initialized signer to sign events
import { createConfig, createSignerWithPrivateKey } from '@lawallet/react';
 
const signer = createSignerWithPrivateKey('5caa3cd87cf1ad069bcf...a7b6070a44ec7223877504c84');
 
export const config = createConfig({
  signer,
});

Return Type

import { type ConfigProps } from '@lawallet/react';

ConfigProps

Type to define the context configuration

export type EndpointsConfigType = {
  lightningDomain: string;
  gateway: string;
};
 
export type ModulePubkeysConfigType = {
  card: string;
  ledger: string;
  urlx: string;
};
 
export type ConfigProps = {
  endpoints: EndpointsConfigType;
  federationId: string;
  modulePubkeys: ModulePubkeysConfigType;
  relaysList: string[];
  storage: BaseStorage;
  signer: NDKSigner | undefined;
};