This project provides an example of how to integrate metapro wallet functionalities into a web application. It demonstrates how to interact directly with the metapro wallet, utilizing all of its functions to enhance user experience. The project is a simple web page that allows users to perform basic operations with the metapro wallet.
The primary objective of this project is to show how to inject metapro wallet functionalities into your web application, enabling direct interaction with the wallet. This includes connecting the wallet, retrieving the wallet address, signing data, and managing user accounts through the metapro API.
Before you begin, ensure you have the following installed:
- Node.js (which includes npm)
Follow these steps to set up and run the project locally:
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
The project will be available at
http://localhost:3000
.
To test the metapro wallet integration, the project needs to be accessible via HTTPS. This is necessary for the metapro mobile app to interact with the wallet. For local testing, you can use ngrok to create a secure tunnel to your local server.
-
Install ngrok globally:
npm install -g ngrok
-
Run ngrok to create a tunnel:
ngrok http 3000
-
Copy the HTTPS URL provided by ngrok and use it in the metapro mobile app for testing.
The project will be accessible at the ngrok URL.
This project supports the following user actions:
-
Connect to Wallet (useEffect)
-
Retrieve Wallet Address (useEffect)
-
Get Signature Hash from the metapro API (handleMetaproLogin)
-
Sign Hash using the metapro wallet (handleMetaproLogin)
-
Check Account Status in metapro (handleMetaproLogin)
- If the account does not exist:
- Create a new account in metapro (an auth token will be provided in the response).
- If the account exists:
- Log in to metapro (an auth token will be provided in the response).
- If the account does not exist:
For more detailed information on metapro integration, please refer to the official metapro documentation.