Skip to content

niallyoung/goNDK

Repository files navigation

goNDK

Run Tests

goNDK is a NOSTR Development Kit in Golang

GOALS

  • well-engineered framework of NOSTR types, funcs and interfaces
  • 95%+ test coverage, for rapid prototyping and production-ready solutions at scale
  • help NOSTR development in Go to be high-quality, fast, easy and fun

STATUS

  • initial type build underway, commenced Easter 2024
  • Event{}
  • Identity{} WIP
  • Client{}, RelayManager{}, Subscription{}, SubscriptionFilter{}
  • Relay{}, Transport{}, ClientManager{},
  • Outbox{}, Inbox{}

DEVELOPMENT

make lint     # golangci-lint
make test     # unit tests
make cover    # 95%+ coverage
make generate # code generation (easyjson)

make docker.build
make docker.lint
make docker.test
make docker.cover
make docker.shell

USAGE

go get github.com/niallyoung/goNDK@latest

Event{}

import (
    "github.com/niallyoung/goNDK/event"
)

// unmarshal an incoming JSON serialised Event
var event event.Event
err := json.Unmarshal([]byte(`{"kind": 1, "content": "...", ... }`), &event)

// create and sign a new event
e := event.NewEvent(1, "hello world!", event.Tags(nil), nil, nil, nil, nil)
err := e.Sign(privateKey.Key.String()) // Sign an Event

// serialization
text := e.String()
bytes := e.Serialize()

// validation
err := e.Validate()
ok, err := e.ValidateSignature()

Identity{}

import (
	"github.com/niallyoung/goNDK/identity"
)

i := identity.NewIdentity(pubkey, npub)
err := i.Validate()

THANKS

Built upon, around and inspired by:

MIT License Copyright (c) 2024 Niall Young [email protected]