Mobile Wallet Protocol provides a way to securely connect dApps to the Metamask mobile wallet, especially when they are running on different devices (e.g., a dApp on a desktop browser or on a react native app).
It acts as a secure bridge, enabling a dApp to send transaction requests and other messages to the mobile wallet and receive responses back, all with end-to-end encryption.
Follow these steps to run the full end-to-end demo on your machine.
- Node.js: Use version 18.x or later.
- Yarn: This repository uses Yarn for package management.
- Docker & Docker Compose: Required to run the backend relay server.
- Expo Go App: To run the mobile wallet demo, you'll need the Expo Go app on your iOS or Android device.
Clone the repository and install all dependencies using Yarn.
git clone https://github.com/your-repo/mobile-wallet-protocol.git
cd mobile-wallet-protocol
yarn install
The relay server runs in a Docker container. Use the provided Docker Compose file to start it.
docker compose -f backend/docker-compose.yml up -d
This command starts the centrifugo
relay server in the background on localhost:8000
. To stop the server, run:
docker compose -f backend/docker-compose.yml down
The web demo is a Next.js application that acts as the dApp.
cd apps/web-demo
yarn dev
Open your browser to http://localhost:3000
to see the dApp interface.
The React Native demo is an Expo application that acts as the mobile wallet.
Important: Your mobile device must be on the same Wi-Fi network as your computer for this to work.
cd apps/rn-demo
yarn start
This will start the Metro bundler and display a QR code in your terminal. Open the Expo Go app on your phone and scan this QR code to launch the wallet demo. The app will automatically detect the local relay server running on your machine.
You can now use the demo wallet on your phone to scan the QR code displayed by the web dApp in your browser to test the full connection flow.
To run all unit and integration tests, use the following command from the root directory:
yarn test
To build all the core packages (core
, dapp-client
, wallet-client
):
yarn build
The project uses Biome for linting and formatting. To check for issues:
yarn lint
To automatically fix formatting issues:
yarn lint:fix
Creating a new release for the packages in this monorepo requires a special script to ensure that only publishable packages are included in the release process.
To initiate a release, run the following command from the root of the project:
yarn release -i
Do not run yarn create-release-branch
directly.
The underlying release tool (@metamask/create-release-branch
) automatically detects all workspaces defined in the root package.json
. By default, this includes our non-publishable demo applications located in the apps/
directory (like web-demo
and rn-demo
).
To work around this, the yarn release
command executes a wrapper script (scripts/create-release.mjs
) that does the following:
- Backs Up and Modifies
package.json
: The script first creates a backup of the originalpackage.json
. It then modifies thepackage.json
file to remove non-publishable workspaces (e.g., the demo apps inapps/*
). - Runs the Release Tool: It executes the underlying release tool (
@metamask/create-release-branch
), which operates only on the publishable packages from the modifiedpackage.json
. - Restores and Updates
package.json
: After the release tool completes, the script reads the new version number. It then restores the originalpackage.json
contents from the backup and updates its version to match the new release version. - Finalizes the Release: Finally, the script removes the backup file and runs
yarn install
andyarn lint:fix
to ensure the project is in a consistent state.
This approach ensures that our development workflow, which relies on Yarn workspaces to link the demo apps with local packages, remains unbroken, while also producing a clean and correct release.