KeybanAccount
The Keyban account is the entry class to access all features related to an account such as balance, token balances, transfers, estimate fees, and sign messages.
Implements
Properties
address
address: `0x${string}`;
Implementation of
KeybanAccount.address
Defined in
packages/sdk-base/src/account.ts:107
publicKey
publicKey: `0x${string}`;
Implementation of
KeybanAccount.publicKey
Defined in
packages/sdk-base/src/account.ts:108
sub
sub: string;
Represents the unique identifier of the client. This data is extracted from the JWT (JSON Web Token).
Implementation of
KeybanAccount.sub
Defined in
packages/sdk-base/src/account.ts:106
Methods
estimateERC20Transfer()
estimateERC20Transfer(options): Promise<FeesEstimation>
Estimates the cost of transferring ERC20 tokens to another address.
Parameters
• options: EstimateERC20TransferParams
The parameters for estimating the ERC20 transfer.
Returns
Promise
<FeesEstimation
>
- A promise that resolves to a
FeesEstimation
object containing the fee details.
Throws
If there is an issue with estimating the gas or fees.
Example
const handleEstimate = async () => {
// account, recipient, contractAddress, amount, setTransferCost are state variables
try {
const valueInWei = BigInt(Number(amount) * 1e18);
const estimation = await account.estimateTransferERC20({
contractAddress: contractAddress as Address,
to: recipient as Address,
value: valueInWei,
});
setTransferCost(estimation.maxFees.toString());
} catch (err) {
console.log(err);
}
};
Implementation of
KeybanAccount.estimateERC20Transfer
Defined in
packages/sdk-base/src/account.ts:362
estimateNftTransfer()
estimateNftTransfer(options): Promise<FeesEstimation>
Estimates the cost of transferring ERC721 and ERC1155 tokens to another address.
Parameters
• options: EstimateNftTransferParams
The parameters for estimating the NFT transfer.
Returns
Promise
<FeesEstimation
>
- A promise that resolves to a
FeesEstimation
object containing the fee details.
Throws
If there is an issue with estimating the gas or fees.
Example
const handleEstimate = async () => {
// account, recipient, contractAddress, tokenId, amount, standard, setTransferCost are state variables
try {
const value = BigInt(amount);
const estimation = await account.estimateNftTransfer({
contractAddress: contractAddress as Address,
tokenId: tokenId as bigint,
to: recipient as Address,
value: value,
standard: standard as 'ERC721' | 'ERC1155',
});
setTransferCost(estimation.maxFees.toString());
} catch (err) {
console.log(err);
}
};
Implementation of
KeybanAccount.estimateNftTransfer
Defined in
packages/sdk-base/src/account.ts:572
estimateTransfer()
estimateTransfer(to): Promise<FeesEstimation>
Estimates the cost of transferring native tokens to another address.
Parameters
• to: `0x${string}`
The recipient's address.
Returns
Promise
<FeesEstimation
>
- A promise that resolves to a
FeesEstimation
object containing the fee details.
Throws
If there is an issue with estimating the gas or fees.
Implementation of
KeybanAccount.estimateTransfer
Defined in
packages/sdk-base/src/account.ts:239
getBalance()
getBalance(): Promise<bigint>
Returns
Promise
<bigint
>
- The account balance in native tokens.
See
Implementation of
KeybanAccount.getBalance
Defined in
packages/sdk-base/src/account.ts:153
getNft()
getNft(tokenAddress, tokenId): Promise<object>
Parameters
• tokenAddress: `0x${string}`
• tokenId: string
Returns
Promise
<object
>
- The account ERC721 and ERC1155 token balances.
balance
balance: bigint;
id
id: string;
imageUrl?
optional imageUrl: null | string;
metadata?
optional metadata: null | JSON;
token
token: object;
token.address
address: `0x${string}`;
token.decimals?
optional decimals: null | number;
token.iconUrl?
optional iconUrl: null | string;
token.name?
optional name: null | string;
token.symbol?
optional symbol: null | string;
token.type?
optional type: null | string;
See
useKeybanAccountNftBalances
Implementation of
KeybanAccount.getNft
Defined in
packages/sdk-base/src/account.ts:177
getNfts()
getNfts(): Promise<object[]>
Returns
Promise
<object
[]>
- The account ERC721 and ERC1155 tokens.
See
Implementation of
KeybanAccount.getNfts
Defined in
packages/sdk-base/src/account.ts:169
getTokenBalances()
getTokenBalances(): Promise<object[]>
Returns
Promise
<object
[]>
- The account balance in ERC20 tokens.
See
Implementation of
KeybanAccount.getTokenBalances
Defined in
packages/sdk-base/src/account.ts:161
signMessage()
signMessage(message): Promise<`0x${string}`>
Signs an Ethereum message.
Parameters
• message: string
The message to be signed.
Returns
Promise
<`0x${string}`>
- The signed message as a hex string.
Throws
If the message is empty or there is an issue during signing.
Implementation of
KeybanAccount.signMessage
Defined in
packages/sdk-base/src/account.ts:143
transfer()
transfer(
to,
value,
txOptions?): Promise<`0x${string}`>
Transfers native tokens to another address.
Parameters
• to: `0x${string}`
The recipient's address.
• value: bigint
The transfer amount in wei (must be greater than 0).
• txOptions?: TransactionOptions
Returns
Promise
<`0x${string}`>
- A promise that resolves to the transaction hash.
Throws
If the recipient's address is invalid or the transfer amount is invalid.
Example
const handleTransfer = async () => {
// amount, account, recipient, setTransactionHash are state variables
try {
const valueInWei = BigInt(Number(amount) * 1e18);
const txHash = await account.transfer(recipient as Address, valueInWei);
setTransactionHash(txHash);
} catch (err) {
console.log(err);
}
};
Implementation of
KeybanAccount.transfer
Defined in
packages/sdk-base/src/account.ts:203
transferERC20()
transferERC20(options): Promise<`0x${string}`>
Transfers ERC20 tokens to another address.
Parameters
• options: TransferERC20Params
The parameters for the ERC20 transfer.
Returns
Promise
<`0x${string}`>
- A promise that resolves to the transaction hash.
Throws
If the recipient's address is invalid, the contract address is invalid, or the transfer amount is invalid.
Example
const handleTransfer = async () => {
// amount, account, recipient, contractAddress, setTransactionHash are state variables
try {
const valueInWei = BigInt(Number(amount) * 1e18);
const txHash = await account.transferERC20({
contractAddress: contractAddress as Address,
to: recipient as Address,
value: valueInWei,
});
setTransactionHash(txHash);
} catch (err) {
console.log(err);
}
};
Implementation of
KeybanAccount.transferERC20
Defined in
packages/sdk-base/src/account.ts:281
transferNft()
transferNft(options): Promise<`0x${string}`>
Transfers ERC721 and ERC1155 tokens to another address.
Parameters
• options: TransferNftParams
The parameters for the NFT transfer.
Returns
Promise
<`0x${string}`>
- A promise that resolves to the transaction hash.
Throws
If the recipient's address is invalid, the contract address is invalid, the transfer amount is invalid, or the token standard is invalid.
Example
const handleTransfer = async () => {
// account, recipient, contractAddress, tokenId, amount, standard, setTransactionHash are state variables
try {
const value = BigInt(amount);
const txHash = await account.transferNft({
contractAddress: contractAddress as Address,
tokenId: tokenId as bigint,
to: recipient as Address,
value: value,
standard: standard as 'ERC721' | 'ERC1155',
});
setTransactionHash(txHash);
} catch (err) {
console.log(err);
}
};
Implementation of
KeybanAccount.transferNft
Defined in
packages/sdk-base/src/account.ts:415