Establishing a Connection
In order to start interacting with Martian Wallet for Sui & Aptos, an app must first establish a connection. This connection request will prompt the user for permission to share their address, indicating that they are willing to interact further. Once permission is established for the first time, the web application's domain will be whitelisted for future connection requests.
Similarly, it is possible to terminate the connection both on the application and the user side.
Connecting
The recommended and easiest way to connect to Martian wallet is by invoking window.martian.connect()
.
The connect()
call will return a Promise that resolves when the user accepts the connection request. An example of the response is given below:
Once the web application is connected to Martian wallet, it will be able to read the connected account's address and publicKey by await window.martian.account()
and will be able to prompt the user for additional transactions. It also exposes a convenience isConnected
.
After a web application connects to Martian wallet for the first time, it becomes whitelisted. Once whitelisted, it's possible for the application to automatically connect to Martian wallet on subsequent visits or page refreshes.
Disconnecting
Disconnecting mirrors the same process as connecting. However, it is also possible for the wallet to initiate the disconnection, rather than the application itself. For this reason, it's important for applications to gracefully handle a disconnect
event.
Last updated