Download

arrow_down

Developer sercices

arrow_down

More

arrow_down
activityactivityactivityactivity
  • themelight
  • languageIcon

  • menu
Skip to Content
EnDocs
Connect Wallet
TutorialAptos

Wallet Standard

MethodParametersReturnsDescription
connectNonePromise<{ publicKey: string; address: string }>Connects to the wallet and returns account info
accountNonePromise<string>Retrieves the current wallet address
isConnectedNonePromise<boolean>Checks if the wallet is currently connected
networkNonePromise<string>Retrieves the current network name or ID
onAccountChangecallback: (address: string) => voidvoidRegisters a callback for account changes
onNetworkChangecallback: (network: string) => voidvoidRegisters a callback for network changes
onDisconnectcallback: () => voidvoidRegisters a callback for disconnection
signTransactiontransaction: object, options?: objectPromise<string>Signs a transaction and returns the signature
signMessagemsg: stringPromise<string>Signs an arbitrary message with the wallet
disconnectNonePromise<void>Disconnects the wallet

Connect to Bitget Wallet

Provider

const provider = window.bitkeep.aptos

Connect

Return

interface ConnectResult { publicKey: string; // your publicKey on aptos address: string; // your address on aptos }

Usage

// @return ConnectResult const response = await provider.connect();

Try It

Loading live editor...

Get Account

Returns

interface AccountResult { publicKey: string; // your publicKey on aptos address: string; // your address on aptos }

Usasge

// @return AccountResult await provider.account();

Network

The user may change accounts while interacting with the DApp, and this can be monitored via onAccountChange.

Parameters

interface AptosAccountChangeCallback { (newAccount: Account): void; }

Usage

window.bitkeep.aptos.onAccountChange((newAccount) => { console.log(newAccount) });

Try It

Loading live editor...

OnNetworkChange

The DApp needs to ensure that the user is connected to the target network, so it needs to get the current network, switch networks, and listen for network changes.

Usage

// Current network let network = await window.bitkeep.aptos.network(); // event listener for network changing window.bitkeep.aptos.onNetworkChange((newNetwork) => { network = newNetwork; // { networkName: 'Mainnet' } })

Sign Message

SignArbitrary

Parameters

interface SignMessagePayload { address?: boolean; // Should we include the address of the account in the message application?: boolean; // Should we include the domain of the dapp chainId?: boolean; // Should we include the current chain id the wallet is connected to message: string; // The message to be signed and displayed to the user nonce: string; // A nonce the dapp should generate }

Return

interface AptosSignatureOutput { chainId: number; // Aptos chain ID (1 = mainnet) application: string; // App origin URL address: string; // Wallet address (hex) publicKey: string; // Wallet public key message: string; // Message to be signed nonce: number; // Unique number to prevent replay prefix: string; // Message prefix (e.g., "APTOS") fullMessage: string; // Full message that was signed signature: string; // Signature of the full message }

Usage

// @params AptosSignatureInput // @return AptosSignatureOutput<Promise> provider.signMessage({nonce: 1234034, message: "hello bitget wallet" })

Try It

Loading live editor...

Transaction

Sign Transaction

Sign a transaction but do not submit it to the Aptos blockchain. Returns the signed transaction, which the DApp then submits.

Parameters

interface TransactionInput { arguments: (string | number)[]; // Parameters passed to the function function: string; // Target function to call (module::function) type: 'entry_function_payload'; // Payload type (fixed value) type_arguments: string[]; // Generic type arguments (e.g., coin type) }

Returns

interface TransactionOutput { }

Usage

// Example Transaction const transaction = { arguments: [address, '717'], function: '0x1::coin::transfer', type: 'entry_function_payload', type_arguments: ['0x1::aptos_coin::TestCoin'], }; // @param TransactionInput // @returns const signTransaction = await provider.signTransaction(transaction)

Send Transaction

there are two ways to send transaction, send by wallet or by dapp

// send transaction by bitget wallet const pendingTransaction = await window.bitkeep.aptos.signAndSubmitTransaction(transaction); // or send transaction by dapp const client = new AptosClient('https://testnet.aptoslabs.com'); client.waitForTransaction(pendingTransaction.hash);
Last updated on