Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,52 @@ Introducing the nostr-java library, a solution written in java for generating, s
- Java 19+

## Usage
To use the library in your project, add the following dependency to your pom.xml file:
To use the library in your project, add the following dependency to your pom.xml file.

Define the value for the most recent version available:
```xml
<properties>
<nostr-java.version>0.6.1-SNAPSHOT</nostr-java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

property:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
is already defined in nostr-java's pom.xml.

your project might have additional explicit dependency for it above and beyond what's required for nostr-java, but that is exclusive to your project and unnecessary here as part of general instruction.

</properties>
```

Add Jitpack to the repositories:
Copy link
Copy Markdown
Collaborator

@avlo avlo Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obtaining nostr-java library jars. Two options:

Option 1: For pre-compiled binaries, add Jitpack to pom.xml repositories:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Option 2: To build and install your own nostr-java binaries:

$ cd <your_git_home_dir>
$ git clone git@github.com:tcheeric/nostr-java.git
$ cd nostr-java
$ git checkout <relevant_branch>
$ mvn clean install

```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
```

Finally add the dependencies:
```xml
<dependency>
<groupId>com.github.tcheeric.nostr-java</groupId>
<artifactId>nostr-java-api</artifactId>
<version>${nostr.java.version}</version>
</dependency>
<dependency>
<groupId>nostr-java</groupId>
<artifactId>nostr-java-api</artifactId>
<version>${nostr-java.version}</version>
</dependency>
<dependency>
<groupId>nostr-java</groupId>
<artifactId>nostr-java-event</artifactId>
<version>${nostr-java.version}</version>
</dependency>
<dependency>
<groupId>nostr-java</groupId>
<artifactId>nostr-java-id</artifactId>
<version>${nostr-java.version}</version>
</dependency>
```


After this is possible to use the library. For example:
```java
Identity RECIPIENT = Identity.generateRandomIdentity();

System.out.println("NSEC: " + RECIPIENT.getPrivateKey().toBech32String());
System.out.println("NPUB: " + RECIPIENT.getPublicKey().toBech32String());
```

I recommend having a look at:
Expand Down