@aptos-labs/derived-wallet-solana

中文文档
0.12.2发布于 2026/03/10Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 1.1万

A light-weight add-on package to the @aptos-labs/wallet-adapter-react that enables the functionality to use a Solana wallet as a Native Aptos Wallet

原始使用文档
文档目录8 节
  1. How does Solana wallet work with the wallet adapter?
  2. How to integrate a Solana wallet in my dApp?
  3. Usage
  4. Option 1: Automatic Wallet Detection (Recommended for dApps)
  5. Option 2: Programmatic Signing (For Node.js/Scripts)
  6. Submitting a Transaction (with Fee Payer)
  7. Considerations
  8. Resources

Derived Wallet Solana

A light-weight add-on package to the @aptos-labs/wallet-adapter-react that enables the functionality to use a Solana wallet as a Native Aptos Wallet

How does Solana wallet work with the wallet adapter?

When a user connects to a dApp using a supported Solana wallet, the adapter computes the user's Derivable Abstracted Account (DAA) address and converts the Solana account to follow the Aptos wallet standard interface. This ensures a seamless interaction with the wallet for both developers and end users.

The computation of the DAA address is done using the authenticationFunction and the accountIdentity, both of which are defined in this package:

  • authenticationFunction: This is a function that exists on-chain and is used to verify the signature of EVM account. The function lives in 0x1::solana_derivable_account::authenticate
  • accountIdentity: This represents the identity of the account used in the on-chain authentication function to verify the signature of the EVM account. The EVM DAA account identity is in the format of: ${originWalletPublicKey}${domain}

How to integrate a Solana wallet in my dApp?

The wallet adapter follows the Solana Wallet Standard to discover wallets. Currently, the wallets that have been tested and support cross-chain accounts are:

Aptos DevnetAptos TestnetAptos Mainnet
Phantom✅✅✅
Solflare✅✅✅
Backpack✅✅✅
OKX✅✅✅

Usage

Note: Ledger hardware wallets do not currently support off-chain message signing required for Solana-derived Aptos accounts. This is a known limitation of the Ledger Solana app. Users should use software wallets (Phantom, Solflare, etc.) without a hardware device connected.

Use this approach when building a dApp where users connect their Solana wallets.

  1. Install the packages
npm install @aptos-labs/wallet-adapter-react @aptos-labs/derived-wallet-solana
  1. Set up automatic detection
import { AptosWalletAdapterProvider, Network } from "@aptos-labs/wallet-adapter-react";
import { setupAutomaticSolanaWalletDerivation } from "@aptos-labs/derived-wallet-solana";

setupAutomaticSolanaWalletDerivation({ defaultNetwork: Network.TESTNET });

// ...

<AptosWalletAdapterProvider
  dappConfig={{
    network: Network.TESTNET,
  }}
>
  {children}
</AptosWalletAdapterProvider>

Option 2: Programmatic Signing (For Node.js/Scripts)

Use this approach for server-side signing or scripts where you have direct access to a Solana keypair.

npm install @aptos-labs/derived-wallet-solana
import { Keypair } from "@solana/web3.js";
import { SolanaDerivedAccount } from "@aptos-labs/derived-wallet-solana";
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

// Create or load a Solana keypair
const solanaKeypair = Keypair.generate();

// Create the derived account
const account = new SolanaDerivedAccount({
  solanaKeypair,
  domain: "my-dapp.com",
});

// Get the derived Aptos address
console.log("Aptos address:", account.accountAddress.toString());

// Sign and submit a transaction
const aptos = new Aptos(new AptosConfig({ network: Network.TESTNET }));

const transaction = await aptos.transaction.build.simple({
  sender: account.accountAddress,
  data: {
    function: "0x1::aptos_account::transfer",
    functionArguments: [recipientAddress, 100],
  },
}),

const response = await aptos.signAndSubmitTransaction({
  signer: account,
  transaction
});

console.log("Transaction hash:", response.hash);

Submitting a Transaction (with Fee Payer)

In most cases, allowing users to submit a transaction with a Solana account to the Aptos chain requires using a sponsor transaction. This is because the Solana account might not have APT to pay for gas. Therefore, the dApp should consider maintaining a sponsor account to sponsor the transactions.

import React from "react";
import { useWallet } from "@aptos-labs/wallet-adapter-react";
import {
  Aptos,
  AptosConfig,
  Network,
  Ed25519PrivateKey,
  PrivateKey,
  PrivateKeyVariants,
  Account,
} from "@aptos-labs/ts-sdk";

// Initialize an Aptos client
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);

// Generate a sponsor account or use an existing account
const privateKey = new Ed25519PrivateKey(
  PrivateKey.formatPrivateKey("0x123", PrivateKeyVariants.Ed25519),
);
const sponsor = Account.fromPrivateKey({ privateKey });

const SignAndSubmit = () => {
  const { account, signTransaction } = useWallet();

  const onSignAndSubmitTransaction = async () => {
    if (!account) {
      throw new Error(
        "Account is not connected and unable to sign transaction",
      );
    }

    try {
      // Build the transaction
      const rawTransaction = await aptos.transaction.build.simple({
        data: {
          function: "0x1::aptos_account::transfer",
          functionArguments: [account.address.toString(), 1],
        },
        sender: account.address,
        withFeePayer: true,
      });

      // Send it to the wallet to sign
      const walletSignedTransaction = await signTransaction({
        transactionOrPayload: rawTransaction,
      });

      // Sponsor account signs the transaction to pay for the gas fees
      const sponsorAuthenticator = aptos.transaction.signAsFeePayer({
        signer: sponsor,
        transaction: rawTransaction,
      });

      // Submit the transaction to chain
      const txnSubmitted = await aptosClient(network).transaction.submit.simple(
        {
          transaction: rawTransaction,
          senderAuthenticator: walletSignedTransaction.authenticator,
          feePayerAuthenticator: sponsorAuthenticator,
        },
      );

      // if you want to wait for transaction
      await aptos.waitForTransaction({ transactionHash: txnSubmitted.hash });
    } catch (error) {
      console.error(error);
    }
  };

  return (
    <button onClick={onSignAndSubmitTransaction}>
      Sign and submit transaction
    </button>
  );
};

export default SignAndSubmit;

Considerations

  • Since the origin wallet most likely not integrated with Aptos, simulation is not available in the wallet.
  • The package retains the origin wallet, so developers should be able to use it and interact with it by:
import { useWallet } from "@aptos-labs/wallet-adapter-react";

const { isSolanaDerivedWallet } = useWallet();

if (isSolanaDerivedWallet(wallet)) {
  const publicKey = wallet.solanaWallet.publicKey;
}

Resources

版本与发布记录

@aptos-labs/derived-wallet-solana 共发布 31 个版本,首次发布于 2025/03/21;过去 12 个月发布了 14 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.12.2latest2026/03/107 个月前
0.12.12026/03/048 个月前
0.12.02026/01/279 个月前
0.11.02026/01/279 个月前
0.11.0-alpha.4alpha2026/01/239 个月前
0.11.0-alpha.32026/01/239 个月前

关于 @aptos-labs/derived-wallet-solana 的常见问题

@aptos-labs/derived-wallet-solana 是什么?

A light-weight add-on package to the @aptos-labs/wallet-adapter-react that enables the functionality to use a Solana wallet as a Native Aptos Wallet

如何安装 @aptos-labs/derived-wallet-solana?

在项目目录运行 npm install @aptos-labs/derived-wallet-solana,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@aptos-labs/ts-sdk(^5.1.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aptos-labs/derived-wallet-solana 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aptos-labs/derived-wallet-solana 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@aptos-labs/derived-wallet-solana 可以商用吗?

@aptos-labs/derived-wallet-solana 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aptos-labs/derived-wallet-solana 的下载量有多少?

根据 npm 官方下载统计,@aptos-labs/derived-wallet-solana 在 2026/10/07 – 2026/11/05 这 30 天内被下载 10,566 次,日均约 352 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aptos-labs/derived-wallet-solana 还在维护吗?

最新版本 0.12.2 发布于 2026/03/10(7 个月前);至今共发布 31 个版本,其中过去 12 个月发布了 14 个;首次发布于 2025/03/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。