SDKs
Learn how to interact with the TRUF.network using SDKs.
The TRUF.network offers SDKs in Go and TypeScript/JavaScript to facilitate seamless integration with its decentralized platform for economic data streams.
What is a streamID
?
A streamID
is an identifier used in the TRUF.network (TN) to identify the deployed contract. It is a unique string generated from a descriptive name, such as an English name, to ensure easy reference and management of data streams.
Go SDK
The Go SDK provides tools to publish, compose, and consume economic data streams within the TRUF.network. It supports operations on primitive streams and composed streams.
Installation:
Ensure you have Go 1.20 or later installed. To install the SDK, run:
Example Usage:
For comprehensive examples and usage patterns, refer to the test files in the SDK repository.
TypeScript/JavaScript SDK
The TypeScript/JavaScript SDK offers similar capabilities as the Go SDK, with implementations tailored for both Node.js and browser environments.
Installation:
Ensure you have Node.js 18 or later installed. To install the SDK, run:
Example Usage:
For detailed examples and usage patterns, refer to the test files and examples in the SDK repository.
Timestamp support
In the contract version 2, we have added support for timestamps. Replacing the Date
type with the number
type in the GetRecordInput
and Record
types.
For more information about the timestamp interface, feel free to navigate to the SDK repository.
Most of the functions and interfaces are the same as the previous version, but with date values replaced with timestamps.
For example, to deploy a new stream with timestamps, you can use the deployPrimitiveStream
function with the contractVersion
parameter set to 2.
Additional Resources
For support or questions, please open an issue in the respective SDK repository or contact our support team.