forked from xmtp/xmtp-quickstart-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrpc.js
More file actions
26 lines (23 loc) · 809 Bytes
/
grpc.js
File metadata and controls
26 lines (23 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { Client } from "@xmtp/xmtp-js";
import { Wallet } from "ethers";
import { GrpcApiClient } from "@xmtp/grpc-api-client";
const grpcOptions = {
env: "production", // or "dev" or "local" depending on your environment
apiUrl: undefined,
skipContactPublishing: false,
apiClientFactory: GrpcApiClient.fromOptions,
// ... any other options you might need
};
const main = async () => {
try {
const client = await Client.create(Wallet.createRandom());
console.log("Non grpc:", client.address);
const clientA = await Client.create(Wallet.createRandom(), grpcOptions);
console.log("Grpc1:", clientA.address);
const clientB = await Client.create(Wallet.createRandom(), grpcOptions);
console.log("Grpc2:", clientB.address);
} catch (e) {
console.log(e);
}
};
main();