Skip to main content

Address & UTXOs

This section is designed to retrieve the wallet address and UTXOs, allowing you to construct your own transaction or utilize the pre-made functions available in this SDK.

getUtxos()

In most cases, it is unlikely that you will need to utilize this function on its own. The typical scenario involves acquiring UTXOs for transaction creation, which should be handled by this SDK. However, there might be specific contexts where you may find the need to employ this function.

import { anvil } from "@ada-anvil/sdk-client";

try {
await anvil.wallet.connect("eternl");
await anvil.wallet.getUtxos(); // Output: ["82825820a...", "82825820a..." , "82825820a...", ...]
} catch {
console.log("YOUR ERROR HANDLING");
}

getChangeAddress()

The function provides an address that is owned by the wallet, specifically intended to serve as a change address during transaction creation. It ensures that any remaining assets can be returned to the connected wallet. Additionally, this address can also be utilized as a general receiving address.

import { anvil } from "@ada-anvil/sdk-client";

try {
await anvil.wallet.connect("eternl");
await anvil.wallet.getChangeAddress(); // Output: "0170334df..."
} catch {
console.log("YOUR ERROR HANDLING");
}

getBech32ChangeAddress()

Return the change address in BECH32. Refer to getChangeAddress() for more info.

import { anvil } from "@ada-anvil/sdk-client";

try {
await anvil.wallet.connect("eternl");
await anvil.wallet.getBech32ChangeAddress(); // Output: "addr1q9crxn0ne...."
} catch {
console.log("YOUR ERROR HANDLING");
}

getBech32StakeAddress()

Return the stake address in BECH32.

import { anvil } from "@ada-anvil/sdk-client";

try {
await anvil.wallet.connect("eternl");
await anvil.wallet.getBech32StakeAddress(); // Output: "stakeq9crxn0ne...."
} catch {
console.log("YOUR ERROR HANDLING");
}