A Avalanche Wallet Client. AvalancheWalletClient
Gets the public key associated with the wallet account.
import { createAvalancheWalletClient } from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
// You can pass a local account otherwise a custom provider can be used
const account = privateKeyToAvalancheAccount("0x...")
const walletClient = createAvalancheWalletClient({
account,
chain: avalanche,
transport: { type: "http" },
})
const pubKey = await walletClient.getAccountPubKey()
// Or you can use a custom provider (e.g. window.avalanche, window.ethereum, etc.)
const walletClient = createAvalancheWalletClient({
chain: avalanche,
transport: { type: "custom", provider: window.avalanche! },
})
const pubKey = await walletClient.getAccountPubKey()
Sends tokens from the source chain to the destination chain.
import { createAvalancheWalletClient } from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const walletClient = createAvalancheWalletClient({
chain: avalanche,
transport: { type: "http" },
})
const result = await walletClient.send({
amount: 1,
to: "0x0000000000000000000000000000000000000000",
Sends an XP transaction to the network.
import { createAvalancheWalletClient } from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
// You can pass a local account otherwise a custom provider can be used
const account = privateKeyToAvalancheAccount("0x...")
const walletClient = createAvalancheWalletClient({
account,
chain: avalanche,
transport: { type: "http" },
})
const result = await walletClient.sendXPTransaction({
amount: "1000000000",
to: "X-avax1...",
assetID: "AVAX"
})
// Or you can use a custom provider (e.g. window.avalanche, window.ethereum, etc.)
const walletClient = createAvalancheWalletClient({
chain: avalanche,
transport: { type: "custom", provider: window.avalanche! },
})
const result = await walletClient.sendXPTransaction({
amount: "1000000000",
to: "X-avax1...",
assetID: "AVAX"
})
Signs a message using the wallet's private key.
import { createAvalancheWalletClient } from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
// You can pass a local account otherwise a custom provider can be used
const account = privateKeyToAvalancheAccount("0x...")
const walletClient = createAvalancheWalletClient({
account,
chain: avalanche,
transport: { type: "http" },
})
const signedMessage = await walletClient.signXPMessage({
message: "Hello Avalanche",
address: "X-avax1..."
})
// Or you can use a custom provider (e.g. window.avalanche, window.ethereum, etc.)
const walletClient = createAvalancheWalletClient({
chain: avalanche,
transport: { type: "custom", provider: window.avalanche! },
})
const signedMessage = await walletClient.signXPMessage({
message: "Hello Avalanche",
address: "X-avax1..."
})
Signs an XP transaction using the wallet's private key.
import { createAvalancheWalletClient } from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
// You can pass a local account otherwise a custom provider can be used
const account = privateKeyToAvalancheAccount("0x...")
const walletClient = createAvalancheWalletClient({
account,
chain: avalanche,
transport: { type: "http" },
})
const signedTx = await walletClient.signXPTransaction({
tx: "0x...",
address: "X-avax1..."
})
// Or you can use a custom provider (e.g. window.avalanche, window.ethereum, etc.)
const walletClient = createAvalancheWalletClient({
chain: avalanche,
transport: { type: "custom", provider: window.avalanche! },
})
const signedTx = await walletClient.signXPTransaction({
tx: "0x...",
address: "X-avax1..."
})
Waits for a transaction to be confirmed on the network.
import { createAvalancheWalletClient } from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'
const walletClient = createAvalancheWalletClient({
chain: avalanche,
transport: { type: "http" },
})
const result = await walletClient.waitForTxn({
txID: "0x...",
chainAlias: "P"
})
Optional
xpAccount?: LocalXPAccount
Creates an Avalanche Wallet Client with a given transport configured for a Chain.
The Avalanche Wallet Client is an interface to interact with the Core Wallet API through Avalanche-specific JSON-RPC API methods.