Aptos Wallet Integration Guide: Connect, Sign & Send Transactions

·

Wallet Standard Methods

MethodParametersReturnsDescription
connectNonePromise<{ publicKey: string; address: string }>Initiates wallet connection
accountNonePromise<AccountResult>Retrieves active wallet address
isConnectedNonePromise<boolean>Verifies connection status
networkNonePromise<string>Fetches current network
onAccountChangecallback: (address: string) => voidvoidHandles account switching
onNetworkChangecallback: (network: string) => voidvoidMonitors network changes
onDisconnectcallback: () => voidvoidTracks disconnection events
signTransactiontransaction: objectPromise<string>Signs transaction data
signMessagemsg: stringPromise<string>Signs custom messages
disconnectNonePromise<void>Terminates wallet session

Initializing the Provider

const provider = window.bitkeep.aptos;

👉 Explore wallet integration examples

Connecting to Wallet

Response Structure

interface ConnectResult {
  publicKey: string; // Base64 encoded public key
  address: string; // 32-byte account address
}

Implementation

const accountInfo = await provider.connect();

Retrieving Account Details

Account Response

interface AccountResult {
  publicKey: string;
  address: string;
}

Usage

const currentAccount = await provider.account();

Network Management

Monitoring Account Changes

provider.onAccountChange((newAccount) => {
  console.log('Account changed:', newAccount);
});

Network Change Events

let activeNetwork = await provider.network();

provider.onNetworkChange((updatedNetwork) => {
  activeNetwork = updatedNetwork;
});

Message Signing

Message Payload

interface SignMessagePayload {
  message: string;
  nonce: string;
  address?: boolean;
  application?: boolean;
  chainId?: boolean;
}

Response Format

interface AptosSignatureOutput {
  signature: string;
  fullMessage: string;
  publicKey: string;
  // ...additional fields
}

Usage Example

const signedMessage = await provider.signMessage({
  message: "Auth request",
  nonce: "123456"
});

👉 Learn advanced signing techniques

Transaction Processing

Transaction Structure

interface TransactionInput {
  function: string;
  arguments: any[];
  type: 'entry_function_payload';
  type_arguments: string[];
}

Signing Transactions

const transaction = {
  function: '0x1::coin::transfer',
  arguments: [recipient, amount],
  type_arguments: ['0x1::aptos_coin::AptosCoin']
};

const signedTx = await provider.signTransaction(transaction);

Submitting Transactions

Two submission methods:

  1. Wallet-Submitted:

    const txHash = await provider.signAndSubmitTransaction(transaction);
  2. DApp-Submitted:

    const client = new AptosClient('RPC_ENDPOINT');
    await client.waitForTransaction(txHash);

FAQ Section

How do I detect wallet installation?

Check for window.bitkeep.aptos existence before calling methods.

What networks does Aptos support?

Mainnet, Testnet, and Devnet - verify using the network() method.

How to handle transaction errors?

Wrap calls in try/catch blocks and check RPC node status.

Can I sign multiple transactions?

Yes, but sequence them to avoid nonce conflicts.

Is there a fee estimator?

Calculate through simulation or use network gas tables.

How to verify message signatures?

Use the Aptos SDK's verification utilities with original message.

👉 View complete developer documentation