You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+234-2Lines changed: 234 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ go get github.com/trufnetwork/sdk-go
41
41
task single:start
42
42
```
43
43
44
-
**Note:** Setting up a local node as described above will initialize an empty database. This setup is primarily for testing the technology or development purposes. If you are a node operator and wish to sync with the Truf Network to access real data, please follow the [Node Operator Guide](https://github.com/trufnetwork/node/blob/main/docs/node-operator-guide.md) for instructions on connecting to the network and syncing data.
44
+
**Note:** Setting up a local node as described above will initialize an empty database. This setup is primarily for testing the technology or development purposes. If you are a node operator and wish to sync with the TRUF.NETWORK to access real data, please follow the [Node Operator Guide](https://github.com/trufnetwork/node/blob/main/docs/node-operator-guide.md) for instructions on connecting to the network and syncing data.
45
45
46
46
4.**Verify Node Synchronization**
47
47
@@ -176,7 +176,7 @@ func main() {
176
176
}
177
177
178
178
// Now you can perform operations on the mainnet
179
-
fmt.Println("Connected to Truf Network Mainnet")
179
+
fmt.Println("Connected to TRUF.NETWORK Mainnet")
180
180
}
181
181
```
182
182
@@ -229,3 +229,235 @@ For additional support or questions, please [open an issue](https://github.com/t
229
229
230
230
The SDK-Go repository is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE.md) for more details.
231
231
232
+
## Stream Creation and Management
233
+
234
+
The TN SDK provides comprehensive support for creating and managing both primitive and composed streams.
235
+
236
+
### Primitive Streams
237
+
238
+
Primitive streams are raw data sources that can represent various types of data points. To create a primitive stream:
Composed streams aggregate and process data from multiple primitive or other composed streams. They use a taxonomy to define how child streams are combined:
For a comprehensive example demonstrating stream creation, taxonomy setup, and data retrieval, see the `examples/complex_stream_example/main.go` file. This example shows:
290
+
291
+
- Deploying primitive streams
292
+
- Inserting records into primitive streams
293
+
- Creating a composed stream
294
+
- Setting up stream taxonomy
295
+
- Retrieving composed stream records
296
+
297
+
Key steps include:
298
+
1. Generating unique stream IDs
299
+
2. Deploying primitive and composed streams
300
+
3. Inserting records into primitive streams
301
+
4. Defining stream taxonomy
302
+
5. Retrieving composed stream records
303
+
304
+
This example provides a practical walkthrough of creating and managing streams in the TRUF.NETWORK ecosystem.
305
+
306
+
### Stream Locators and Data Providers
307
+
308
+
#### Stream Locators
309
+
310
+
A `StreamLocator` is a unique identifier for a stream that consists of two key components:
311
+
1.`StreamId`: A unique identifier for the stream
312
+
2.`DataProvider`: The Ethereum address of the stream's creator/owner
313
+
314
+
The `OwnStreamLocator()` method is a convenience function that automatically creates a `StreamLocator` using:
315
+
- The provided `StreamId`
316
+
- The current client's Ethereum address
317
+
318
+
Example:
319
+
```go
320
+
// Creates a StreamLocator with:
321
+
// - The given stream ID
322
+
// - The current client's address as the data provider
This is particularly useful when you're creating and managing your own streams, as it automatically uses your client's address.
327
+
328
+
#### Data Providers
329
+
330
+
A `DataProvider` is the Ethereum address responsible for creating and managing a stream. When inserting records or performing operations on a stream, you need to specify the data provider's address.
331
+
332
+
To get the current client's address, use:
333
+
```go
334
+
// Get the current client's Ethereum address
335
+
dataProviderAddress:= tnClient.Address()
336
+
337
+
// Get the address as a string for use in stream operations
The Truf Node SDK offers a comprehensive set of APIs for interacting with the TN, allowing developers to create, manage, and consume data streams. This document provides detailed descriptions of all available methods in the SDK, along with examples of their usage.
3
+
## TRUF.NETWORK SDK Overview
4
+
5
+
The TRUF.NETWORK SDK provides a comprehensive toolkit for developers to interact with decentralized data streams. It enables seamless creation, management, and consumption of economic and financial data streams.
6
+
7
+
### Key Features
8
+
- Stream creation and management
9
+
- Primitive and composed stream support
10
+
- Flexible data retrieval
11
+
- Advanced permission management
12
+
- Secure, blockchain-backed data streams
4
13
5
14
## Interfaces
6
-
-[Client](client.md)
7
-
-[Primitive Stream](primitive-stream.md)
8
-
-[Composed Stream](composed-stream.md)
9
15
10
-
Other utilities are in the [util](util.md) documentation.
16
+
The SDK is structured around several key interfaces:
11
17
12
-
## Example Usage
18
+
-[Client](client.md): Primary entry point for network interactions
19
+
-[Primitive Stream](primitive-stream.md): Raw data stream management
20
+
-[Composed Stream](composed-stream.md): Aggregated data stream handling
21
+
22
+
## Core Concepts
23
+
24
+
### Streams
25
+
-**Primitive Streams**: Direct data sources with raw data points
26
+
-**Composed Streams**: Aggregated streams combining multiple data sources
13
27
14
-
Below is an example demonstrating how to use the TN SDK to deploy, initialize, and read from a primitive stream.
28
+
### Data Management
29
+
- Secure, immutable data recording
30
+
- Flexible querying and indexing
31
+
- Granular access control
32
+
33
+
## Example Usage
15
34
16
35
```go
17
36
package main
18
37
19
38
import (
20
39
"context"
21
-
"fmt"
22
-
"github.com/golang-sql/civil"
23
-
"github.com/kwilteam/kwil-db/core/crypto"
24
-
"github.com/kwilteam/kwil-db/core/crypto/auth"
25
40
"github.com/trufnetwork/sdk-go/core/tnclient"
26
41
"github.com/trufnetwork/sdk-go/core/types"
27
42
"github.com/trufnetwork/sdk-go/core/util"
28
-
"time"
29
43
)
30
44
31
45
funcmain() {
32
-
// handle errors appropriately in a real application
Please refer to the test files in the SDK repository for more examples and detailed usage patterns. These tests provide comprehensive examples of various stream operations and error-handling scenarios.
0 commit comments