Skip to content

Commit

Permalink
Add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jul 7, 2024
1 parent 9a4e2f1 commit e204d94
Showing 1 changed file with 72 additions and 14 deletions.
86 changes: 72 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,81 @@
# Arduino Nostr Library
# Nostrduino

Nostr: A simple, open protocol that enables a truly censorship-resistant and global social network.
A [nostr-tools](https://github.com/nbd-wtf/nostr-tools) inspired library for Arduino (and other) microcontrollers.

This library gives the ability to interact with Nostr relays with Arduino microcontrollers.
This was created using [arduino-nostr](https://github.com/lnbits/arduino-nostr) as starting point, most of the code was rewritten and the library was expanded to include more features.

## Compatibility
This library is compatible with esp32 microcontrollers out of the box.
But it can be ported to other microcontrollers by reimplementing the platform specific code in the `src/esp32`.

## Features

+ NostrEvent - For creation of NIP01 and NIP04 notes
+ NostrRelayManager - For management of multiple relays and message broadcasting and receiving
+ NostrQueueProcessor - For queueing up relay messages
+ NostrRequestOptions - For creating a request object that can be sent to relays
+ [Nip01](https://github.com/nostr-protocol/nips/blob/master/01.md) : Basic protocol flow
+ [Nip04](https://github.com/nostr-protocol/nips/blob/master/04.md) : Encrypted messages
+ [Nip47](https://github.com/nostr-protocol/nips/blob/master/04.md) : Nostr Wallet Connect
+ [(bonus) Lightning Address](https://lightningaddress.com/) : Can request invoices from lightning addresses
+ [NWC managed service](src/services/NWC.h) : A managed service to interact with NWC


## Philosophy
This library is built with a DIY philosophy in mind, similar to nostr-tools, this library provides helpers to create, sign and verify messages and to use some of the NIPs features (see the `src/Nip*` files).

In addition to that, the library provides some "managed" services (in `src/services` folder) that you can use in your sketches without worrying about the details and complexity of the nostr protocol.

## Installation

+ Send notes and private messages with support for NIP01 kind 1 and NIP04 kind 4.
+ Receieve and decrypt NIP04 messages.
+ Broadcast messages to multiple relays with the ability to specify custom callbacks for NIP01, NIP04, and OK messages.
+ Add messages to a queue for broadcasting once relays are connected.
+ Subscribe to relay events using REQ messages.
+ Specify a minimum number of relays required for broadcasting and specify a timeout to ensure messages are broadcast even if the minimum number of relays is not reached.
TODO

## Usage
See the example scripts in `examples/` for simple examples of how to use this library.


## Development
### Setting up the build environment

```bash
# create venv
python3 -m venv venv
# activate venv
source venv/bin/activate
# install platformio
pip install platformio
```



### Compiling Tests

#### Test NIP01
Edit `examples/ESP32TestNip01/ESP32TestNip01.cpp` and set the `WIFI_SSID`, `WIFI_PASS` and `WIFI_CHANNEL`.

Then compile with:
```
pio run -e ESP32TestNip01
```


### Test NIP04

Compile with:
```
pio run -e ESP32TestNip04
```


### Test NWC
Edit `examples/ESP32TestNWC/ESP32TestNWC.cpp` and set the `WIFI_SSID`, `WIFI_PASS` , `WIFI_CHANNEL` and `NWC_URL`.
NB: you can get a nwc url from [https://nwc.getalby.com/](https://nwc.getalby.com/) or [https://app.mutinywallet.com/settings/connections](https://app.mutinywallet.com/settings/connections).

Then compile with:
```
pio run -e ESP32TestNWC
```

### Running tests
You can upload the compiled tests to your ESP32 with:
```
pio run -e TEST_NAME -t upload
```

See the example scripts in `examples/` for simple examples of how to use this library.
or use an emulator like [wokwi](https://wokwi.com/).

0 comments on commit e204d94

Please sign in to comment.