nip26 3.0.0 copy "nip26: ^3.0.0" to clipboard
nip26: ^3.0.0 copied to clipboard

A Dart library for Nostr NIP-26 Delegated Event Signing.

Dart implementation of Delegated Event Signing in Nostr as described in NIP-26.

Features #

This package lets you create delegation tokens as a delegator, construct delegated events as a delegatee and check and get the delegator from an event as a client.

Usage #

import 'package:nip26/nip26.dart';
import 'package:nip01/nip01.dart';

final delegatorRootKeyPair = KeyPair.generate();
final delegator = Delegator(delegatorRootKeyPair);

final delegateeKeyPair = KeyPair.generate();

final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
final conditions = ConditionsQuery(
    kinds: [EventKind.textNote.value],
    createdAfter: now,
    createdBefore: now + 600,
);

final token = delegator.createDelegationToken(
    delegateePubkey: delegateeKeyPair.publicKey,
    conditionsQuery: conditions,
);

final delegatee = Delegatee(
    delegateeKeyPair,
    delegatorPubkey: delegatorRootKeyPair.publicKey,
    conditions: conditions,
    token: token,
);

final event = delegatee.constructSignedEvent(
    createdAt: now + 1,
    kind: EventKind.textNote.value,
    content: 'Hello, World in name of delegator!',
);

final delegator = Client.tryGetDelegatorOfEvent(event);

Additional information #

This package is part of the Dartstr monorepo, which contains a set of modular and compatible Dart packages of different Nostr NIPS and utilities. Import just the packages of NIPS you need and keep your project lightweight. See the Dartstr monorepo for all available packages.

0
likes
160
points
2
downloads

Publisher

verified publisherkumuly.dev

Weekly Downloads

A Dart library for Nostr NIP-26 Delegated Event Signing.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

bip340, convert, crypto, equatable, nip01

More

Packages that depend on nip26