Guide for creating a wallet extension

In this tutorial we will be using «Petra Aptos Wallet». This tutorial tells you how to install the Petra extension and how to use it in your dApp.

  1. Install Petra in Chrome
  2. Wallet functionality
  3. Integrating a dApp

Step 1: Install Wallet in Chrome

  1. Go to the Petra extension installation guide page.
  2. Click the Add to Chrome button.

You should now see «Petra Aptos Wallet» in your Chrome extensions!

Hint: Open the downloaded extension by clicking on the puzzle piece icon on the Chrome toolbar.

Step 2: Wallet functionality

The wallet introduces some basics of interacting with Aptos

  • Create new account
  • Top up your account with test coins
  • Send coins to another address
  • Link to account resources in Explorer
  • View and create NFT
  • Select different networks

Step 3: Integration of dApps

DApps can make requests to the wallet from their site:


// import transaction build from aptos sdk:
import { BCS, TxnBuilderTypes } from 'aptos';

// Establish connection to the wallet
const result = await (window as any).aptos.connect()

// Check connection status of wallet
const status = await (window as any).aptos.isConnected()

// Gets the address of the account signed into the wallet
const accountAddress = await (window as any).aptos.account()

// Create a transaction
const transaction = {
    arguments: [address, '717'],
    function: '0x1::coin::transfer',
    type: 'entry_function_payload',
    type_arguments: ['0x1::aptos_coin::AptosCoin'],

// Send transaction to the extension to be signed and submitted to chain
const response = await (window as any).aptos.signAndSubmitTransaction(transaction)

// Send transaction to the extension to be signed and returns
const signedTransaction = await (window as any).aptos.signTransaction(transaction)

// Disconnect dApp from the wallet
await (window as any).aptos.disconnect(transaction)
Enter fullscreen mode Exit fullscreen mode

Оцените статью
Добавить комментарий