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:83
publicKey
publicKey: `0x${string}`;
Implementation of
KeybanAccount.publicKey
Defined in
packages/sdk-base/src/account.ts:84
sub
sub: string;
Implementation of
KeybanAccount.sub
Defined in
packages/sdk-base/src/account.ts:82
Methods
estimateERC20Transfer()
estimateERC20Transfer(object:): Promise<FeesEstimation>
Estimates the cost of transferring ERC20 tokens to another address.
Parameters
• object:: 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:330
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:207
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:129
getNft()
getNft(): Promise<object[]>
Returns
Promise
<object
[]>
The account ERC721 and ERC1155 tokens.
See
Implementation of
KeybanAccount.getNft
Defined in
packages/sdk-base/src/account.ts:145
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:137
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:119
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:171
transferERC20()
transferERC20(param0): Promise<`0x${string}`>
Transfers ERC20 tokens to another address.
Parameters
• param0: 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:249