Skip to content

vedant-asati/aptos-snap

Repository files navigation

MetaMask Snap for Aptos

NPM Version Netlify Status

Aptos Connect is a MetaMask Snap that allows users to interact with the Aptos blockchain directly from MetaMask. This snap provides various Aptos-related functionalities, such as generating accounts, signing messages, and sending transactions.

Live Demo

Installation

To use Aptos Connect in your project, install the npm package:

npm install aptos-connect

Features

  • Account Management: Generate new Aptos accounts, view public and private keys, and get account addresses.
  • Transaction Signing: Sign and send Aptos transactions, including funding accounts and transferring Aptos coins.
  • Message Signing: Sign arbitrary messages directly from MetaMask.
  • Data Persistence: Save and retrieve data across sessions.
  • RPC Interaction: Perform RPC requests to Aptos nodes for account balances, transaction history, and more.

Project Structure

...
packages/
  site/        # Frontend application built using Gatsby
    src/
      components/  # React components for UI
      pages/       # Main app pages (index.tsx)
      utils/       # Helper functions
  snap/        # MetaMask Snap logic
    src/
      cryptoUtils.ts    # Utility functions for key management
      index.tsx         # Main Snap logic, handling RPC requests
      utils.ts          # Aptos-specific utilities
...

RPC Methods

  • getAccountAddress: Retrieve the Aptos account address for a given derivation path.
  • getPublicKey: Get the public key for the specified derivation path.
  • getPrivateKey: Obtain the private key (sensitive).
  • createNewAccount: Generate a new Aptos account.
  • signMessage: Sign a message with the private key.
  • sign&sendTxn: Sign and send a transaction on the Aptos blockchain.
  • setData: Save data in metamask's encrypted storage.
  • getData: Retrieve data.
  • clearData: Clear all data.

Check more about all rpc methods here.

Development

To run the project locally, clone the repository and install dependencies using Yarn:

git clone https://github.com/vedant-asati/aptos-snap.git
yarn install
yarn start

Frontend development:

cd packages/site
yarn install
yarn start

Snap development:

cd packages/snap
yarn install
yarn start

Using the snap

The production snap is available as Snap ID: npm:aptos-connect.

The locally started snap is available as Snap ID: local:http://localhost:8080.

License

This project is licensed under the Apache 2.0 License and MIT License.

Releases

No releases published

Packages

No packages published