How to Integrate

Aptos offers the @aptos-labs/wallet-standard package, which includes both the standard interface and class implementation for wallets. Additionally, it provides utility functions for identifying Aptos-compatible wallets.

There are three main steps to implement the AIP-62 wallet standard in your wallet.

AptosWallet interface implementation

A wallet must implement an AptosWallet interface with the wallet provider info and features:


export default class MyWallet implements AptosWallet {
// region AptosWallet
readonly name = 'MyWallet';
readonly version = '1.0.0';
readonly icon = 'my_icon';
readonly url = 'my_url';
readonly chains = APTOS_CHAINS;
get accounts() {
return this.activeAccount ? [new MyAccount(this.activeAccount)] : [];
}
get features(): AptosFeatures {
return {
[AptosConnectNamespace]: {
connect: this.connect.bind(this),
version: '1.0.0',
},
[AptosDisconnectNamespace]: {
disconnect: this.disconnect.bind(this),
version: '1.0.0',
},
[AptosGetAccountNamespace]: {
account: this.getAccount.bind(this),
version: '1.0.0',
},
[AptosGetNetworkNamespace]: {
network: this.getNetwork.bind(this),
version: '1.0.0',
},
[AptosOnAccountChangeNamespace]: {
onAccountChange: this.onAccountChange.bind(this),
version: '1.0.0',
},
[AptosOnNetworkChangeNamespace]: {
onNetworkChange: this.onNetworkChange.bind(this),
version: '1.0.0',
},
[AptosSignMessageNamespace]: {
signMessage: this.signMessage.bind(this),
version: '1.0.0',
},
[AptosSignTransactionNamespace]: {
signTransaction: this.signTransaction.bind(this),
version: '1.0.0',
},
};
}
// endregion
// MyWallet
private activeAccount: AccountInfo | undefined = undefined;
private readonly client: MyClient;
constructor() {
const transport = new MyApiWindowTransport(window);
this.client = new MyApiClient(transport);
// Initialize accounts
void this.client.isConnected().then(async (isConnected) => {
if (isConnected) {
const account = await this.client.getAccount();
this.activeAccount = myAccountToAccountInfo(account);
}
});
}

AptosWalletAccount interface implementation

A wallet must implement a AptosWalletAccount interface that represents the accounts that have been authorized by the dapp.


export default class MyAccount implements AptosWalletAccount {
// region AptosWalletAccount
readonly chains = APTOS_CHAINS;
get address() {
return this.#address.toString();
}
get publicKey() {
return this.#publicKey.toUint8Array();
}
get signingScheme() {
if (this.#publicKey instanceof Ed25519PublicKey) {
return SigningScheme.Ed25519;
}
if (this.#publicKey instanceof MultiEd25519PublicKey) {
return SigningScheme.MultiEd25519;
}
if (this.#publicKey instanceof AnyPublicKey) {
return SigningScheme.SingleKey;
}
if (this.#publicKey instanceof MultiKey) {
return SigningScheme.MultiKey;
}
throw new Error("Unsupported public key type");
}
readonly label?: string;
readonly features = [];
// endregion
// region MyAccount
readonly #address: AccountAddress;
readonly #publicKey: PublicKey;
constructor({ address, ansName, publicKey }: AccountInfo) {
this.#publicKey = publicKey;
this.#address = address;
this.label = ansName;
}
// endregion
}

These are the required features that wallet should support and implement here.


const REQUIRED_FEATURES: (keyof MinimallyRequiredFeatures)[] = [
"aptos:account",
"aptos:connect",
"aptos:disconnect",
"aptos:network",
"aptos:onAccountChange",
"aptos:onNetworkChange",
"aptos:signMessage",
"aptos:signTransaction",
];


Register Wallet

Web extension wallet A wallet registers itself using the registerWallet method to notify the dapp it is ready to be registered.


import { registerWallet } from "@aptos-labs/wallet-standard";
const myWallet = new MyWallet();
registerWallet(myWallet);

You can check the wallet adapter repo for a complete example