Skip to main content

Class.KeybanAccount

Abstract account bound to a specific chain implementation (EVM, Starknet, Stellar). Provides methods to sign messages and to transfer/estimate fees for native currency, ERC‑20-like tokens, and NFTs, when supported by the target network. Obtain an instance via KeybanClient.initialize.

See

KeybanClient

Constructors

Constructor

new KeybanAccount(api: IKeybanApi): KeybanAccount;

Internal

Internal constructor used by chain-specific clients.

Parameters

ParameterTypeDescription
apiIKeybanApiKeyban API facade for remote operations.

Returns

KeybanAccount

Properties

PropertyModifierTypeDescription
addressabstractstringThe blockchain address associated with the account.
publicKeyabstractstringThe public key associated with the account.

Methods

estimateERC20Transfer()

abstract estimateERC20Transfer(params: EstimateERC20TransferParams): Promise<FeesEstimation>;

Estimate maximum fees for an ERC‑20 token transfer.

Parameters

ParameterTypeDescription
paramsEstimateERC20TransferParamsTransfer parameters without explicit fees.

Returns

Promise<FeesEstimation>

Promise resolving to FeesEstimation.

Throws

On estimation failure.

Example

import { KeybanClient, KeybanNetwork, type Address } from "@keyban/sdk-base";
const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: KeybanNetwork.EthereumAnvil });
const account = await client.initialize();
const estimation = await account.estimateERC20Transfer({
contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" as Address,
to: "0x0000000000000000000000000000000000000001" as Address,
value: 1_000_000n,
});
console.log(estimation.details);

estimateNftTransfer()

abstract estimateNftTransfer(params: EstimateNftTransferParams): Promise<FeesEstimation>;

Estimate maximum fees for an NFT transfer (ERC‑721 / ERC‑1155).

Parameters

ParameterTypeDescription
paramsEstimateNftTransferParamsNFT estimation parameters (without explicit fees).

Returns

Promise<FeesEstimation>

Promise resolving to FeesEstimation.

Throws

On estimation failure or invalid parameters.

Example

import { KeybanClient, KeybanNetwork, type Address } from "@keyban/sdk-base";
const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: KeybanNetwork.EthereumAnvil });
const account = await client.initialize();
const estimation = await account.estimateNftTransfer({
contractAddress: "0xDEF..." as Address,
tokenId: 456n,
to: "0x0000000000000000000000000000000000000001" as Address,
value: 5n,
standard: "ERC1155",
});
console.log(estimation.maxFees);

estimateTransfer()

abstract estimateTransfer(to: string): Promise<FeesEstimation>;

Estimate maximum fees to transfer native currency.

Parameters

ParameterTypeDescription
tostringRecipient address.

Returns

Promise<FeesEstimation>

Promise resolving to FeesEstimation.

Throws

On estimation failure.

Example

import { KeybanClient, KeybanNetwork, type Address } from "@keyban/sdk-base";
const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: KeybanNetwork.EthereumAnvil });
const account = await client.initialize();
const recipient: Address = "0x0000000000000000000000000000000000000001";
const estimation = await account.estimateTransfer(recipient);
console.log(estimation.maxFees.toString());

signMessage()

abstract signMessage(message: string): Promise<string | string[]>;

Sign a message with the account's key material.

Parameters

ParameterTypeDescription
messagestringThe message to sign.

Returns

Promise<string | string[]>

Promise resolving to the signature. EVM returns hex, Stellar returns base64 string.

Throws

On signing failures.

See

KeybanClient

Example

import { KeybanClient, KeybanNetwork } from "@keyban/sdk-base";

const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: KeybanNetwork.EthereumAnvil });
const account = await client.initialize();
const signature = await account.signMessage("Hello Keyban");
console.log(signature);

transfer()

abstract transfer(
to: string,
value: bigint,
fees?: FeeDetails): Promise<string>;

Transfer native currency to a recipient.

Parameters

ParameterTypeDescription
tostringRecipient address.
valuebigintAmount to transfer in the smallest unit (e.g., wei, stroop).
fees?FeeDetailsOptional network-specific fee parameters.

Returns

Promise<string>

Promise resolving to the transaction hash/string.

Throws

SdkErrorTypes.AddressInvalid | SdkErrorTypes.AmountInvalid

Example

import { KeybanClient, KeybanNetwork, type Address } from "@keyban/sdk-base";

const client = new KeybanClient({
apiUrl: "https://api.prod.keyban.io",
appId: "YOUR_APP_ID",
network: KeybanNetwork.EthereumAnvil,
});
const account = await client.initialize();

const recipient: Address = "0x0000000000000000000000000000000000000001";
const value = 1_000_000_000_000_000_000n; // 1 ETH in wei
const txHash = await account.transfer(recipient, value);
console.log(txHash);

transferERC20()

abstract transferERC20(params: TransferERC20Params): Promise<string>;

Transfer ERC‑20-like fungible tokens.

Parameters

ParameterTypeDescription
paramsTransferERC20ParamsTransfer parameters.

Returns

Promise<string>

Promise resolving to the transaction hash/string.

Throws

SdkErrorTypes.AddressInvalid | SdkErrorTypes.AmountInvalid | SdkErrorTypes.RecipientAddressEqualsSender

Example

import { KeybanClient, KeybanNetwork, type Address } from "@keyban/sdk-base";

const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: KeybanNetwork.EthereumAnvil });

const txHash = await account.transferERC20({
contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" as Address, // USDC
to: "0x0000000000000000000000000000000000000001" as Address,
value: 1_000_000n, // 1 USDC (6 decimals)
});
console.log(txHash);

transferNft()

abstract transferNft(params: TransferNftParams): Promise<`0x${string}`>;

Transfer an NFT (ERC‑721 / ERC‑1155).

Parameters

ParameterTypeDescription
paramsTransferNftParamsNFT transfer parameters.

Returns

Promise<`0x${string}`>

Promise resolving to the transaction hash.

Throws

SdkErrorTypes.AddressInvalid | SdkErrorTypes.RecipientAddressEqualsSender | SdkErrorTypes.AmountRequired | SdkErrorTypes.AmountInvalid | SdkErrorTypes.AmountIrrelevant | SdkErrorTypes.InvalidNftStandard

Example

import { KeybanClient, KeybanNetwork, type Address } from "@keyban/sdk-base";

const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: KeybanNetwork.EthereumAnvil });
const account = await client.initialize();

// ERC-721
await account.transferNft({
contractAddress: "0xABC..." as Address,
tokenId: 123n,
to: "0x0000000000000000000000000000000000000001" as Address,
standard: "ERC721",
});

// ERC-1155
await account.transferNft({
contractAddress: "0xDEF..." as Address,
tokenId: 456n,
to: "0x0000000000000000000000000000000000000001" as Address,
value: 5n,
standard: "ERC1155",
});