Class.KeybanClient
Main client for interacting with the Keyban API and associated services. This class provides methods to initialize accounts, retrieve balances, query NFTs, and interact with the Keyban blockchain.
Remarks
The KeybanClient
serves as the primary interface for developers to interact with
the Keyban ecosystem. It handles authentication, communication with the Keyban API,
and provides utility methods for common tasks.
Example
// Initialize the client
const client = new KeybanClient({
apiUrl: "https://api.prod.keyban.io",
appId: "your-app-id",
network: KeybanNetwork.EthereumAnvil,
});
// Initialize an account
const account = await client.initialize();
See
Extends
KeybanClientBase
Constructors
Constructor
new KeybanClient(config: KeybanClientConfig): KeybanClient;
Creates a new instance of KeybanClient
.
Parameters
Parameter | Type | Description |
---|---|---|
config | KeybanClientConfig | The configuration object to initialize the client. |
Returns
KeybanClient
Throws
If the configuration is invalid.
Example
const client = new KeybanClient({
apiUrl: "https://api.prod.keyban.io",
appId: "your-app-id",
network: KeybanNetwork.EthereumAnvil,
});
Overrides
KeybanClientBase.constructor
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
apiUrl | URL | The Keyban API URL, defaulting to "https://api.prod.keyban.io". | KeybanClientBase.apiUrl |
apolloClient | ApolloClient <NormalizedCacheObject > | The Apollo GraphQL client used for making API requests. | KeybanClientBase.apolloClient |
appId | string | The application ID used for authentication with the Keyban API. | KeybanClientBase.appId |
network | KeybanNetwork | The blockchain used by Keyban. | KeybanClientBase.network |
Accessors
api
Get Signature
get api(): IKeybanApi;
Returns
Inherited from
KeybanClientBase.api
feesUnit
Get Signature
get feesUnit(): FeesUnit;
Retrieves the fee unit configuration based on the current network.
Maps supported networks to their fee unit details, including symbol and number of decimals. Supported configurations include:
- EthereumAnvil & PolygonAmoy: symbol "gwei", decimals 9
- StarknetDevnet, StarknetSepolia & StarknetMainnet: symbol "FRI", decimals 18
- StellarQuickstart, StellarTestnet & StellarMainnet: symbol "stroop", decimals 7
Returns
The fee unit configuration for the active network.
Inherited from
KeybanClientBase.feesUnit
nativeCurrency
Get Signature
get nativeCurrency(): NativeCurrency;
Retrieves the native currency details associated with the current network.
Returns an object that includes the native currency's name, symbol, and decimal precision for the active KeybanClientBase.network.
Returns
The native currency information for the current network.
Inherited from
KeybanClientBase.nativeCurrency
Methods
apiStatus()
apiStatus(): Promise<KeybanApiStatus>;
Performs a health check on the Keyban API to determine its operational status.
Returns
Promise
<KeybanApiStatus
>
- A promise resolving to the API status, either
"operational"
or"down"
.
Example
const status = await client.apiStatus();
console.log(`API Status: ${status}`);
Throws
Throws an error if the health check request fails.
See
Inherited from
KeybanClientBase.apiStatus
initialize()
initialize(): Promise<KeybanAccount>;
Initializes a KeybanAccount
associated with the current client.
This method sets up the account by retrieving or generating the client share,
and prepares the account for transactions and other operations.
Returns
Promise
<KeybanAccount
>
- A promise that resolves to an instance of
KeybanAccount
.
Throws
If initialization fails due to signing errors.
Example
const account = await client.initialize();
console.log(`Account address: ${account.address}`);
See
Overrides
KeybanClientBase.initialize