-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yuki Kishimoto <[email protected]>
- Loading branch information
Showing
5 changed files
with
51 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// ANCHOR: full | ||
import Foundation | ||
import NostrSDK | ||
|
||
func hello() async throws { | ||
// ANCHOR: client | ||
let keys = Keys.generate() | ||
let signer = NostrSigner.keys(keys: keys) | ||
let client = Client(signer: signer) | ||
// ANCHOR_END: client | ||
|
||
// ANCHOR: connect | ||
try await client.addRelay(url: "wss://relay.damus.io") | ||
await client.connect() | ||
// ANCHOR_END: connect | ||
|
||
// ANCHOR: publish | ||
let builder = EventBuilder.textNote(content: "Hello, rust-nostr!") | ||
let output = try await client.sendEventBuilder(builder: builder) | ||
// ANCHOR_END: publish | ||
|
||
// ANCHOR: output | ||
print("Event ID: \(try output.id.toBech32())") | ||
print("Sent to: \(output.success)") | ||
print("Not sent to: \(output.failed)") | ||
// ANCHOR_END: output | ||
} | ||
// ANCHOR_END: full |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters