Receiving Data
Receiving data on the Synternet involves three main steps:
- Authorize your agent to connect to the network.
- Subscribe to services from the marketplace.
- Consume the data programmatically in your application using an SDK.
While it's technically possible to do everything through node CLI and raw blockchain transactions, it is error-prone and not recommended. The Portal provides a more straightforward, user-friendly way to register projects, manage access tokens, and subscribe to services. Once that setup is complete, you can interact with the data programmatically through SDKs or basic CLI tools.
We assume you already have the Keplr wallet installed and connected with some mainnet SYNT or testnet AMBER token. If not, please return to the previous section to set up your wallet.
Prerequisites
Before continuing, make sure the following are in place:
- You have the Keplr wallet installed in your browser.
- Wallet is connected to either mainnet (with SYNT tokens) or testnet (with AMBER tokens).
Refer to the wallet setup guide if you haven't set this up yet.
Authorizing Your Agent
You must create a project in the Synternet Portal to access the Synternet network. To create a project, navigate to the Interact tab in the Synternet Portal (testnet, mainnet) and click on New project.
Each project has:
- A name is filled during the creation of a project and used by the user purely for organizational purposes.
- An access token — a secret key derived from your wallet signature. Available once you create a project by clicking on the specific project ellipsis menu and the Reveal Access Token button.
This access token is what your agent will use to authenticate itself when fetching data. At this point, you can already use this access token to connect to the Synternet network. However, you will not be able to receive or send any data.
// npm i [email protected]:Synternet/pubsub-js.git
import { createAppJwt, NatsService } from "pubsub-js";
const accessToken = "secret-project-revealed-access-token";
async function main() {
const service = new NatsService({
url: "europe-west3-gcp-dl-testnet-brokernode-frankfurt01.synternet.com",
natsCredsFile: createAppJwt(accessToken),
});
await service.waitForConnection().catch((err) => {
console.error("Failed to connect.", err);
process.exit(1);
});
console.info("Connected!");
}
main();
The Synternet network is a proof-of-authority messaging layer that connects to the Synternet blockchain to verify user access. It is responsible for delivering messages between agents.
- Mainnet
- Testnet
broker-eu-01.synternet.com
broker-eu-02.synternet.com
broker-eu-03.synternet.com
europe-west3-gcp-dl-testnet-brokernode-frankfurt01.synternet.com
europe-west3-gcp-dl-testnet-brokernode-frankfurt02.synternet.com
europe-west3-gcp-dl-testnet-brokernode-frankfurt03.synternet.com
Use one of the Synternet network node URLs above to connect your agent to the Synternet network, depending on whether you're working on mainnet or testnet.
A typical pattern is creating one project per agent and using its access token in your agent's configuration or environment. While technically possible to use a single project across multiple agents or many projects per agent, this is uncommon and can complicate access control and setup. Keeping one project per agent simplifies management and debugging.
Subscribing to Services
At this point, you should already be able to connect to the Synternet network. With projects being available, you can subscribe to services:
- Go to your project in the Portal (testnet, mainnet).
- Click Add New Service to browse and select the services you want to access.
- Confirm the transaction to add a service. You'll be prompted to reserve credits (mainnet SYNT or testnet AMBER token). Reserved tokens enable the network to meter your usage in real time.
Reserved credits are not instantly spent. If you remove a service subscription, unused tokens can be claimed back.
Consuming the Data
All services linked to a project are accessible with the same token, making it easy to manage access per agent. How you consume data differs depending on whether the data you subscribe to is a stream-like or RPC-like service. Stream-like service continuously pushes to your client without requests, and RPC-like data responds to your requests.
- Stream
- RPC
// npm i [email protected]:Synternet/pubsub-js.git
import { createAppJwt, NatsService } from "pubsub-js";
const accessToken =
"secret-project-revealed-access-token";
const streamSubject = "synternet.ethereum.tx";
async function main() {
const service = new NatsService({
url: "europe-west3-gcp-dal-devnet-brokernode-cluster01.synternet.com",
natsCredsFile: createAppJwt(accessToken),
});
await service.waitForConnection();
service.addHandler(streamSubject, (encoded) => {
const data = new TextDecoder().decode(encoded);
console.log(data);
});
await service.serve();
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
// npm i [email protected]:Synternet/pubsub-js.git
import { createAppJwt, NatsService } from "pubsub-js";
const accessToken =
"secret-project-revealed-access-token";
const rpcSubject = "synternet.osmosis.rpc";
const rpcRequest = '{"endpoint":"header","params":{"height":"20121934"}}';
async function main() {
const service = new NatsService({
url: "europe-west3-gcp-dal-devnet-brokernode-cluster01.synternet.com",
natsCredsFile: createAppJwt(accessToken),
});
await service.waitForConnection();
const msg = await service.request(rpcSubject, rpcRequest);
console.info(new TextDecoder().decode(msg.data));
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
See the Synternet SDKs page for support in additional programming languages. Most SDKs also include usage examples and extended documentation in their respective repositories.
Before using an SDK, you can preview and interact with your subscribed services directly in the Synternet Portal.
Once services are added, click Interact in your project to view live data. You'll see two types of services (if available):
- Stream – continuous data pushed in real-time
- RPC – on-demand replies to specific requests
If your project contains both, the Interact window will show tabs for each. If only one type exists, it defaults to that type.
Before writing any code, this interface lets you quickly confirm that your services are active and data flows correctly.
Next up: publishing your data to the network.