npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@phoenix-wallet/aptos

v1.0.7

Published

Aptos chain support for Phoenix Wallet

Downloads

117

Readme

@phoenix-wallet/aptos

Aptos blockchain support for Phoenix Wallet - comprehensive wallet adapter for Aptos ecosystem.

Overview

This package provides full support for Aptos blockchain, including wallet connectors for popular Aptos wallets like Petra, Pontem, Nightly, and OKX.

Features

  • 🔌 Multiple Wallet Support: Petra, Pontem, Nightly, OKX, and more
  • 🌐 Network Support: Mainnet, Testnet, Devnet, and custom networks
  • 📝 Move Contracts: Easy interaction with Move smart contracts
  • 🔐 Signing: Message and transaction signing support
  • 💰 Coin Operations: Native APT and custom coin transfers
  • Type Safety: Full TypeScript support with Aptos SDK v4

Installation

# Using pnpm (recommended)
pnpm add @phoenix-wallet/core @phoenix-wallet/aptos @aptos-labs/ts-sdk

# Using npm
npm install @phoenix-wallet/core @phoenix-wallet/aptos @aptos-labs/ts-sdk

# Using yarn
yarn add @phoenix-wallet/core @phoenix-wallet/aptos @aptos-labs/ts-sdk

Quick Start

Basic Setup

import { WalletProvider } from '@phoenix-wallet/core';
import { 
  PetraAptosConnector, 
  OKXAptosConnector,
  AptosNetwork 
} from '@phoenix-wallet/aptos';

const aptosChainConfigs = [
  {
    id: 'aptos_mainnet',
    name: 'Aptos Mainnet',
    chainId: 'mainnet',
    rpcUrl: 'https://fullnode.mainnet.aptoslabs.com/v1',
    nativeCurrency: {
      name: 'Aptos Coin',
      symbol: 'APT',
      decimals: 8
    },
    blockExplorerUrl: 'https://explorer.aptoslabs.com'
  },
  {
    id: 'aptos_testnet',
    name: 'Aptos Testnet',
    chainId: 'testnet',
    rpcUrl: 'https://fullnode.testnet.aptoslabs.com/v1',
    nativeCurrency: {
      name: 'Aptos Coin',
      symbol: 'APT',
      decimals: 8
    },
    blockExplorerUrl: 'https://explorer.aptoslabs.com?network=testnet'
  }
];

const connectors = [
  new PetraAptosConnector({
    id: 'petra-aptos',
    name: 'Petra',
    logo: 'https://petra.app/logo.png',
    network: AptosNetwork.MAINNET,
    dappMetadata: {
      name: 'My DApp',
      url: 'https://mydapp.com',
      icon: 'https://mydapp.com/icon.png'
    }
  }),
  new OKXAptosConnector({
    id: 'okx-aptos',
    name: 'OKX Wallet',
    logo: 'https://okx.com/logo.png',
    network: AptosNetwork.MAINNET,
    dappMetadata: {
      name: 'My DApp',
      url: 'https://mydapp.com',
      icon: 'https://mydapp.com/icon.png'
    }
  })
];

function App() {
  return (
    <WalletProvider connectors={connectors} chainConfigs={aptosChainConfigs}>
      <YourApp />
    </WalletProvider>
  );
}

Using the Wallet

import { useWallet } from '@/hooks/useWallet';
import { APTOS_COIN } from '@aptos-labs/ts-sdk';

function WalletComponent() {
  const { 
    wallet, 
    isConnected, 
    address, 
    connect, 
    disconnect 
  } = useWallet('petra-aptos');

  const handleConnect = async () => {
    await connect();
  };

  const handleSignMessage = async () => {
    if (!wallet) return;
    const signature = await wallet.signMessage('Hello, Aptos!');
    console.log('Signature:', signature);
  };

  const handleTransferAPT = async () => {
    if (!wallet) return;
    
    const txHash = await wallet.sendTransaction({
      payload: {
        function: '0x1::coin::transfer',
        typeArguments: [APTOS_COIN],
        functionArguments: [
          'recipient_address',
          100000000 // 1 APT (8 decimals)
        ]
      }
    });
    
    console.log('Transaction hash:', txHash);
  };

  return (
    <div>
      {!isConnected ? (
        <button onClick={handleConnect}>Connect Petra</button>
      ) : (
        <div>
          <p>Connected: {address}</p>
          <button onClick={handleSignMessage}>Sign Message</button>
          <button onClick={handleTransferAPT}>Transfer APT</button>
          <button onClick={disconnect}>Disconnect</button>
        </div>
      )}
    </div>
  );
}

Available Connectors

Petra Wallet

import { PetraAptosConnector, AptosNetwork } from '@phoenix-wallet/aptos';

const petra = new PetraAptosConnector({
  id: 'petra-aptos',
  name: 'Petra',
  logo: 'https://petra.app/logo.png',
  network: AptosNetwork.MAINNET,
  dappMetadata: {
    name: 'My DApp',
    url: 'https://mydapp.com',
    icon: 'https://mydapp.com/icon.png'
  }
});

OKX Wallet

import { OKXAptosConnector, AptosNetwork } from '@phoenix-wallet/aptos';

const okx = new OKXAptosConnector({
  id: 'okx-aptos',
  name: 'OKX Wallet',
  logo: 'https://okx.com/logo.png',
  network: AptosNetwork.MAINNET,
  dappMetadata: {
    name: 'My DApp',
    url: 'https://mydapp.com'
  }
});

Pontem Wallet

import { PontemAptosConnector, AptosNetwork } from '@phoenix-wallet/aptos';

const pontem = new PontemAptosConnector({
  id: 'pontem-aptos',
  name: 'Pontem',
  logo: 'https://pontem.network/logo.png',
  network: AptosNetwork.MAINNET,
  dappMetadata: {
    name: 'My DApp',
    url: 'https://mydapp.com'
  }
});

Nightly Wallet

import { NightlyAptosConnector, AptosNetwork } from '@phoenix-wallet/aptos';

const nightly = new NightlyAptosConnector({
  id: 'nightly-aptos',
  name: 'Nightly',
  logo: 'https://nightly.app/logo.png',
  network: AptosNetwork.MAINNET,
  dappMetadata: {
    name: 'My DApp',
    url: 'https://mydapp.com'
  }
});

Network Configuration

Available Networks

enum AptosNetwork {
  MAINNET = 'mainnet',
  TESTNET = 'testnet',
  DEVNET = 'devnet',
  CUSTOM = 'custom'
}

Custom Network Configuration

const connector = new PetraAptosConnector({
  id: 'petra-aptos',
  name: 'Petra',
  logo: 'https://petra.app/logo.png',
  network: AptosNetwork.CUSTOM,
  customNodeUrl: 'https://your-custom-node.com/v1',
  dappMetadata: { /* ... */ }
});

Transaction Operations

Simple Transfer

import { APTOS_COIN } from '@aptos-labs/ts-sdk';

const txHash = await wallet.sendTransaction({
  payload: {
    function: '0x1::coin::transfer',
    typeArguments: [APTOS_COIN],
    functionArguments: [
      recipientAddress,
      amount // in Octas (1 APT = 100,000,000 Octas)
    ]
  }
});

Sign and Submit Transaction

const transaction = await wallet.chain.provider.transaction.build.simple({
  sender: wallet.address,
  data: {
    function: '0x1::coin::transfer',
    typeArguments: [APTOS_COIN],
    functionArguments: [recipientAddress, amount]
  }
});

// Sign only
const signedTx = await wallet.signTransaction(transaction);

// Or sign and submit
const txHash = await wallet.sendTransaction({ payload: transaction.data });

Multi-Agent Transactions

const transaction = await wallet.chain.provider.transaction.build.multiAgent({
  sender: wallet.address,
  secondarySignerAddresses: [secondaryAddress],
  data: {
    function: '0x1::your_module::multi_agent_function',
    typeArguments: [],
    functionArguments: [/* ... */]
  }
});

const signedTx = await wallet.signTransaction(transaction);

Move Contract Interactions

Using AptosContract

import { AptosContract } from '@phoenix-wallet/aptos';

const contract = new AptosContract(
  '0x1::coin', // Module address
  wallet
);

// View function (read-only)
const balance = await contract.call('balance', [
  { type: 'address', value: wallet.address }
]);

// Entry function (write)
const txHash = await contract.send('transfer', [
  { type: 'address', value: recipientAddress },
  { type: 'u64', value: amount }
]);

Custom Module Interaction

const moduleAddress = '0x123...abc';
const moduleName = 'my_module';

const result = await wallet.sendTransaction({
  payload: {
    function: `${moduleAddress}::${moduleName}::my_function`,
    typeArguments: ['0x1::aptos_coin::AptosCoin'],
    functionArguments: [arg1, arg2, arg3]
  }
});

Coin Operations

Get Balance

// Get APT balance
const balance = await wallet.getBalance();
console.log(`Balance: ${balance} APT`);

// Get custom coin balance
import { Aptos, AptosConfig, Network } from '@aptos-labs/ts-sdk';

const aptos = new Aptos(new AptosConfig({ network: Network.MAINNET }));
const coinType = '0x1::aptos_coin::AptosCoin';
const resources = await aptos.getAccountResources({ accountAddress: wallet.address });
const coinResource = resources.find(r => r.type === `0x1::coin::CoinStore<${coinType}>`);
const balance = coinResource?.data?.coin?.value;

Register Coin

const txHash = await wallet.sendTransaction({
  payload: {
    function: '0x1::managed_coin::register',
    typeArguments: [coinType],
    functionArguments: []
  }
});

Message Signing

Sign Text Message

const message = 'Hello, Aptos!';
const signature = await wallet.signMessage(message);

// Signature format
console.log(signature.signature); // hex string
console.log(signature.fullMessage); // full message with nonce

Verify Signature

import { Aptos, AptosConfig, Network } from '@aptos-labs/ts-sdk';

const aptos = new Aptos(new AptosConfig({ network: Network.MAINNET }));
const isValid = await aptos.verifyMessageSignature({
  message: originalMessage,
  signature: signature.signature,
  signer: wallet.address
});

API Reference

AptosWallet

class AptosWallet {
  address: string;
  chain: AptosChain;
  connector: AptosConnector;
  walletClient: AptosWalletClient;
  
  // Get APT balance
  getBalance(): Promise<string>;
  
  // Sign message
  signMessage(message: string): Promise<{ signature: string; fullMessage: string }>;
  
  // Sign transaction
  signTransaction(transaction: any): Promise<any>;
  
  // Send transaction
  sendTransaction(transaction: any): Promise<string>;
  
  // Send raw transaction
  sendRawTransaction(signedTx: string): Promise<string>;
}

AptosChain

class AptosChain {
  id: string;
  name: string;
  network: AptosNetwork;
  nodeUrl: string;
  provider: Aptos;
  
  getBalance(address: string): Promise<string>;
  getAccountInfo(address: string): Promise<any>;
}

Error Handling

try {
  await wallet.sendTransaction(transaction);
} catch (error) {
  if (error.code === 4001) {
    console.log('User rejected the transaction');
  } else if (error.message.includes('INSUFFICIENT_BALANCE')) {
    console.log('Insufficient balance');
  } else if (error.message.includes('SEQUENCE_NUMBER_TOO_OLD')) {
    console.log('Transaction sequence number is outdated');
  } else {
    console.error('Transaction failed:', error);
  }
}

TypeScript Support

Full TypeScript support with comprehensive type definitions:

import type { 
  AptosWallet, 
  AptosChain, 
  AptosConnector,
  AptosWalletClient,
  AptosNetwork 
} from '@phoenix-wallet/aptos';

Related Packages

Resources

License

MIT

Support

For issues and questions, please visit our GitHub repository.