Skip to main content

Class.KeybanAccount

Abstract account bound to a specific chain implementation (EVM, 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, Network, type Address } from "@keyban/sdk-base";
const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: Network.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, Network, type Address } from "@keyban/sdk-base";
const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: Network.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, value: bigint): Promise<FeesEstimation>;

Estimate maximum fees to transfer native currency.

Parameters​

ParameterTypeDescription
tostringRecipient address.
valuebigint-

Returns​

Promise<FeesEstimation>

Promise resolving to FeesEstimation.

Throws​

On estimation failure.

Example​

import { KeybanClient, Network, type Address } from "@keyban/sdk-base";
const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: Network.EthereumAnvil });
const account = await client.initialize();
const recipient: Address = "0x0000000000000000000000000000000000000001";
const estimation = await account.estimateTransfer(recipient, 1_000_000_000_000_000_000n);
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, Network } from "@keyban/sdk-base";

const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: Network.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​

SdkErrorCode.AddressInvalid | SdkErrorCode.AmountInvalid

Example​

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

const client = new KeybanClient({
apiUrl: "https://api.prod.keyban.io",
appId: "YOUR_APP_ID",
network: Network.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​

SdkErrorCode.AddressInvalid | SdkErrorCode.AmountInvalid | SdkErrorCode.RecipientAddressEqualsSender

Example​

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

const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: Network.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​

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

Example​

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

const client = new KeybanClient({ apiUrl: "https://api.prod.keyban.io", appId: "YOUR_APP_ID", network: Network.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",
});