Wallet Adapter Plugin for SDK Wallets
A wallet adapter plugin allows dapps to use your wallet. With the AIP-62 Wallet standard, dapps can simply update their version of aptos-wallet-adapter
to connect to newly added Wallet plugins.
Implementing a wallet plugin for an SDK wallet which can be imported via npm has two main steps:
- Implement a wallet adapter plugin for your SDK wallet.
- Publish your plugin on npm.
- Update the
aptos-wallet-adapter
package to let dapps know about your wallet.
1. Implement the Wallet Adapter Plugin.
You can use the wallet-standard
repo’s example to implement an AIP-62 compatible wallet adapter plugin that dapps can automatically recognize.
For an example of how to implement the Wallet Adapter plugin, see the Wallet Adapter Demo dapp. Specifically, standardWallet.ts
contains the plugin implementation, and page.tsx
has the React components.
Create a new typescript repository.
Copy the wallet-standard
example into that new repo.
Follow the instructions in that example to make it use your wallet to execute the AIP-62 functions.
The full list of required functions for AIP-62 compatible wallets can be found here.
Test your changes by:
Clone the aptos-wallet-adapter
repository.
Navigate to aptos-wallet-adapter/apps/nextjs-example/src/utils/standardWallet.ts
in the example dapp.
Replace standardWallet.ts
with your implementation of the AIP-62 standard.
- You will have to update the import in
aptos-wallet-adapter/apps/nextjs-example/src/app/page.tsx
to use your Wallet instead ofMyWallet
. - For local testing purposes, you can leave the
registerWallet
code, but SDK wallets do not need that once they have been added to theaptos-wallet-standard
core package.
Run a local version of the dapp by following the instructions in the README.md.
Click “Connect a Wallet”
You should see your wallet on the list of connections.
Connect to your wallet.
- You can then use the demo dapp features to verify your other wallet features work as expected.
- This simulates how a real dapp will interact with your wallet.
2. Once tested, publish a new npm package for your SDK wallet code by following this guide. (Ex. AptosConnect)
3. Update wallet-adapter-core
to know about your extension.
In order for dapp users who are not already using your wallet to get the option to create an account with your wallet, you need to update wallet-adapter-core
with your browser extension’s download link.
Fork the aptos-wallet-adapter
monorepo. (Link to fork)
Open your fork in a local editor such as VSCode.
Create a new branch for your changes.
git checkout -b your-wallet
Navigate to packages/wallet-adapter-core/src/AIP62StandardWallets
.
Import your SDK wallet npm package.
pnpm i @yourpackage
Import your wallet in sdkWallets.ts
.
For example with AptosConnect:
import { AptosConnectWallet } from "@aptos-connect/wallet-adapter-plugin";
Add code to push an instance of your wallet to sdkWallets
inside getSDKWallets
(in sdkWallets.ts
).
sdkWallets.push(new YourWallet(dappConfig));
Some wallets may have custom logic required to make sure the right wallet is connected when the user clicks to “sign in” with your Wallet.
Ex. T Wallet has different Wallet plugins for mainnet and devnet connections.
In type.ts
, update the type AvailableWallets
to include your wallet’s name.
export type AvailableWallets = "Nightly" | "Petra" | "T wallet" | "Your Wallet's Name";
Update the README.md at the top-level of the aptos-wallet-adapter
to include your wallet in the list of AIP-62 compatible wallets.
Commit and push your changes to your fork.
If you have pushed your changes to your fork, a green button should appear at the top of the aptos-wallet-adapter
repo asking if you would like to create a pull request.
Follow this guide to open a pull request for the aptos-wallet-adapter
repo.
Once the changes are merged, dapps that update their aptos-wallet-adapter
package versions will now be able to see your Wallet.
Resources
- Wallet Adapter Demo App
- Live site
- Source code
- See
standardWallet.ts
for an example implementation of an AIP-62 compatible wallet-adapter plugin.
wallet-standard
source code.wallet-adapter-core
source code.- AIP-62 standard.