You can configure the NODE_URL with https://portal0101.sending.network to connect to a public Edge Node.
Make sure to replace YOUR_WALLET_ADDRESS , YOUR_PRIVATE_KEY and YOUR_DEV_KEY with the actual value.
3. Create an Instance of SDNClient
After setting up the configuration file, you can create an instance of the SDNClient class. This will allow you to interact with the SendingNetwork API.
// preLogin to get a message to sign
let auth = new SDNAuth(nodeUrl)
let loginMessage = await auth.didPreLogin(address)
let web3 = new Web3()
// sign with wallet account key
let walletSignature = web3.eth.accounts.sign(loginMessage["message"], key)
// sign with developer key (add '0x' prefix if necessary)
let developerKeySignature = web3.eth.accounts.sign(loginMessage["message"], developerKey)
// didLogin to get access token
let loginResp = await auth.didLoginWithAppToken(address,
loginMessage["did"], loginMessage["message"], walletSignature["signature"], developerKeySignature["signature"],
loginMessage["random_server"], loginMessage["updated"])
let accessToken = loginResp["access_token"]
// create SDNClient with a storage file
let storage = new SimpleFsStorageProvider("/path/to/bot/storage/file");
let client = new SDNClient(nodeUrl, accessToken, storage);
// register message listener
client.on("room.message", async (roomId: string, event: any) => {
LogService.info("index", roomId, event);
});
// start syncing
await client.start();
4. Interact with the SDK
Once you have created an instance of SDNClient and started syncing with the SendingNetwork server, you can use the SDK to perform various actions. Here are a few examples:
You will need a developer key to access the Edge Network. For further insight into the mechanism and to request a developer key, please consult the provided guide .