XMTP
XMTP is a messaging protocol which helps you build apps that communicate with every wallet in the world, and weâre huge fans here at Dynamic!
In this guide youâll learn how to set up an example XMTP application using Dynamic as the authentication layer, and learn how it all works.
The running version of what youâre about to build can be found here: https://xmtp-quickstart-reactjs.matthew18091.repl.co/
Run the quickstart
All youâll need to get going is a code editor and a terminal! When youâre ready, clone the official XMTP React quickstart, which ships with Dynamic:
git clone https://github.com/fabriguespe/xmtp-quickstart-reactjs/
Navigate to the xmtp-quickstart-reactjs directory, and run npm i && npm run dev
to install the dependancies and start the app.
Open it up on whichever ports it displays for you, and you should see a simple app with a button that says âConnect Walletâ.
Connect an Etherium supported wallet i.e. Metamask, and you should see a new button called âConnect XMTPâ appear. Click it, and youâll be prompted to sign a message in your wallet.
Those two steps could be combined into one for ease of use, but weâve kept them separate here to show you how it works under the hood.
Thatâs it! Youâre authenticated and connected. You can now send messages to wallet addresses, and theyâll be able to see them in real time.
How it works
The Dynamic integration
Take a look in App.tsx and youâll see that things get wrapped in DynamicContextProvider. This makes sure that Dynamic is available to your components.
If you check the import for this provider at the top of the file, youâll see itâs imported from sdk-react-core
. This is important.
The -core
signifies that we are using the modular version of the SDK, where you pick and choose which chain/wallet providers you want to import and thus keep the bundle size as small as possible.
This is why youâll also see an EthereumWalletConnectors
import, which is the Ethereum wallet connector from Dynamic. Itâs passed in through the settings prop on the DynamicContextProvider, like this:
<DynamicContextProvider
settings={{
walletConnectors: [ EthereumWalletConnectors ]
}}
>
As you can see, The other setting passed in is the environment ID for the Dynamic environment you want to use. You can find this in the developer section of the Dynamic dashboard but weâve given you a default demo ID to get started with.
Next take a look at the Home
component, where youâll find a lot of different XMTP functionality If you want to learn more, the docs detail the entire SDK and methods available: https://xmtp.org/docs/build/get-started
What next?
Discover some of the advanced use cases XMTP and Dynamic can provide! You can find use case examples for XMTP here and Dynamic examples in the left hand nav here.