Metamask Snap to enable Metamask users interaction with Aptos.
Aptos Snap is the application allowing users to directly manage Aptos within the MetaMask interface. Since Snaps is pre-release software, the alpha version of Aptos Snap is currently live on Metamask Flask only, a canary distribution for developers that provides access to upcoming features.
*Note: MetaMask Flask is an experimental playground for developers and is not to be confused with the normal MetaMask wallet app.
Snaps is a system that allows developers to safely build and expand the capabilities of MetaMask. It is a program that is run in an isolated environment with a limited set of capabilities, that can customize and modify MetaMask's wallet experience for end users. For example, a snap can add new APIs to MetaMask thus adding support for different blockchains or modify existing functionalities using internal APIs.
Additional information can be found here.
packages
├── adapter # Aptos Snap adapter is used integrate Aptos Snap into your dapp.
├── demo # a simple demo to interact with aptos snap
└── snap # Aptos Snap is the Snap application which run in the MetaMask Flask.
import WalletAdapter from '@keystonehq/aptossnap-adapter';
//Enable `Aptos Snap` in your dapp
await walletAdapter.connect();
// Get an Aptos Public Account
const account = walletAdapter.publicAccount;
console.log(account.address); // 0xdc14ee7ed551b16e6f0d06da40767d9eb3f38d286d6842692993355385a2795d
console.log(account.publicKey); // 0xfa59a4f07139eaa8c8b6cf77a55d398d65792501d28edca9e9cdb997052b158f
// Sign Transaction
const transactionPayload = {
arguments: [
'0x1f410f23447ae2ad00e931b35c567783a5beb3b5d92c604f42f912416b7c3ccd',
2,
],
function: '0x1::coin::transfer',
type: 'entry_function_payload',
type_arguments: ['0x1::aptos_coin::AptosCoin'],
};
const txHash = await walletAdapter.signAndSubmitTransaction(
transactionPayload,
);
console.log(txHash);
- Create a new browser profile or disable/uninstall any existing versions of Metamask
- Download MetaMask Flask
- Head over to the Aptos Snap webpage, create a test wallet, connect it to MetaMask Flask and approve the installation of the Aptos Snap app
- Start experimenting
This project is dual-licensed under Apache 2.0 and MIT terms: