Skip to content

Commit 84cb592

Browse files
committed
helper for address
1 parent 16457af commit 84cb592

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,32 @@ for (const conversation of conversations) {
6969
}
7070
```
7171

72+
## Working with addresses
73+
74+
Because XMTP is interoperable, you may interact with inboxes that are not on your app. In these scenarios, you will need to find the appropriate inbox ID or address.
75+
76+
```tsx
77+
// get an inbox ID from an address
78+
const inboxId = await getInboxIdForIdentifier({
79+
identifier: "0x1234567890abcdef1234567890abcdef12345678",
80+
identifierKind: IdentifierKind.Ethereum,
81+
});
82+
83+
// find the addresses associated with an inbox ID
84+
const inboxState = await client.inboxStateFromInboxIds([inboxId]);
85+
86+
interface InboxState {
87+
inboxId: string;
88+
recoveryIdentifier: Identifier;
89+
installations: Installation[];
90+
identifiers: Identifier[];
91+
}
92+
93+
const addresses = inboxState.identifiers
94+
.filter((i) => i.identifierKind === IdentifierKind.Ethereum)
95+
.map((i) => i.identifier);
96+
```
97+
7298
## Web inbox
7399

74100
Interact with the XMTP network using [xmtp.chat](https://xmtp.chat), the official web inbox for developers.

0 commit comments

Comments
 (0)