The TRUF.NETWORK (TN) provides granular control over stream access and visibility. This document outlines the permission system, how to configure it, and best practices for securing your streams.
TN supports two main types of permissions:
- Read Permissions: Control who can read data from a stream.
- Compose Permissions: Determine which streams can use this stream as a child in a composed stream.
Streams can be set to one of two visibility states:
- Public: Accessible to all users.
- Private: Accessible only to specifically allowed wallets or streams.
To set a stream's visibility:
// Set read visibility
txHash, err := stream.SetReadVisibility(ctx, util.PrivateVisibility)
if err != nil {
// Handle error
}
// Set compose visibility
txHash, err := stream.SetComposeVisibility(ctx, util.PublicVisibility)
if err != nil {
// Handle error
}For private streams, you can allow specific wallets to read data:
txHash, err := stream.AllowReadWallet(ctx, readerAddress)
if err != nil {
// Handle error
}You can allow specific streams to use your stream as a child in composition:
txHash, err := stream.AllowComposeStream(ctx, composedStreamLocator)
if err != nil {
// Handle error
}To revoke previously granted permissions:
// Revoke read permission
txHash, err := stream.DisableReadWallet(ctx, readerAddress)
if err != nil {
// Handle error
}
// Revoke compose permission
txHash, err := stream.DisableComposeStream(ctx, composedStreamLocator)
if err != nil {
// Handle error
}You can query the current permission settings:
// Check read visibility
visibility, err := stream.GetReadVisibility(ctx)
if err != nil {
// Handle error
}
// Get allowed read wallets
allowedWallets, err := stream.GetAllowedReadWallets(ctx)
if err != nil {
// Handle error
}
// Get allowed compose streams
allowedStreams, err := stream.GetAllowedComposeStreams(ctx)
if err != nil {
// Handle error
}This configuration allows anyone to read the stream data, but only specific streams can use it in composition.
stream.SetReadVisibility(ctx, util.PublicVisibility)
stream.SetComposeVisibility(ctx, util.PrivateVisibility)
stream.AllowComposeStream(ctx, allowedStreamLocator)Only specific wallets can read the stream data, but any stream can use it in composition.
stream.SetReadVisibility(ctx, util.PrivateVisibility)
stream.SetComposeVisibility(ctx, util.PublicVisibility)
stream.AllowReadWallet(ctx, allowedReaderAddress)Both reading and composing are restricted to specifically allowed entities.
stream.SetReadVisibility(ctx, util.PrivateVisibility)
stream.SetComposeVisibility(ctx, util.PrivateVisibility)
stream.AllowReadWallet(ctx, allowedReaderAddress)
stream.AllowComposeStream(ctx, allowedStreamLocator)- Changing permissions requires blockchain transactions. Always wait for transaction confirmation before assuming the change has taken effect.
To ensure the integrity and quality of data streams on the TRUF.NETWORK, the creation of new streams (both primitive and composed) is a permissioned operation. This process is governed by a system:network_writer role within the network's role-based access control (RBAC) system.
Only wallets that are members of the system:network_writer role are authorized to deploy new streams using the SDK's DeployStream or BatchDeployStreams functions.
How to get access:
If you are a partner or data provider interested in deploying streams on the TRUF.NETWORK, please contact our team. We will guide you through the process of obtaining the necessary permissions by granting your wallet the system:network_writer role.
The SDK provides an API for advanced partners and internal use to programmatically interact with the role management system. These functions allow for granting, revoking, and checking role memberships.
Client.LoadRoleManagementActions(): Loads theIRoleManagementinterface.IRoleManagement.GrantRole(ctx, GrantRoleInput, ...TxOpt): Grants a role to one or more wallets.IRoleManagement.RevokeRole(ctx, RevokeRoleInput, ...TxOpt): Revokes a role from one or more wallets.IRoleManagement.AreMembersOf(ctx, AreMembersOfInput): Checks if one or more wallets are members of a specific role.IRoleManagement.ListRoleMembers(ctx, ListRoleMembersInput): Lists current members of a role with optional pagination.
Note: For general stream creation, users should typically contact the TRUF.NETWORK team directly rather than attempting to manage the system:network_writer role themselves. The system:network_writer role is managed by system:network_writers_manager.
By leveraging these permission controls, you can create secure, flexible data streams that meet your specific needs while maintaining control over your valuable data within the TN ecosystem.