Skip to main content

Overview

The Giza class is the primary entry point of the SDK. It manages authentication, HTTP transport, and chain-scoped configuration. Use it to create Agent handles, query protocol data, run the optimizer, and check system health.

Constructor

Creates a new SDK client. See the GizaConfig reference for all available options.
GizaConfig
required
Configuration object specifying the target chain and credentials.
The constructor validates all inputs and resolves environment variable fallbacks. It throws a ValidationError if any required credential is missing or if the chain ID is invalid.

Environment Variable Fallback

When a credential is omitted from the constructor config, the SDK reads the corresponding environment variable: If neither the config field nor the environment variable is set, the constructor throws a ValidationError with a message indicating which value is missing.

Agent Factory Methods

These methods create or retrieve Agent handles bound to a specific smart-account wallet address.

agent(wallet)

Returns an Agent handle for a known smart-account address without making any API call. Use this when you already have the smart-account address stored (for example, from a previous createAgent call).
Address
required
The smart-account wallet address (0x-prefixed hex string).
Returns: Agent

createAgent(eoa)

Creates a new smart account for the given externally-owned account (EOA) and returns an Agent bound to the new smart-account address.
Address
required
The user’s externally-owned account address.
Returns: Promise<Agent> — the Agent is bound to the newly created smart-account address.

getAgent(eoa)

Looks up an existing smart account by EOA and returns an Agent bound to it. Use this when the smart account was created previously and you need to recover the handle.
Address
required
The user’s externally-owned account address.
Returns: Promise<Agent>

getSmartAccount(eoa)

Returns full smart-account metadata (address, backend wallet, origin wallet, chain) without creating an Agent handle. Useful when you need the raw account data.
Address
required
The user’s externally-owned account address.
Returns: Promise<SmartAccountInfo>

Chain-Level Queries

These methods query data scoped to the chain configured on the Giza client.

protocols(token)

Returns the list of active protocol names available for a given token on the current chain.
Address
required
The token contract address.
Returns: Promise<ProtocolsResponse>{ protocols: string[] }

protocolSupply(token)

Returns supply data for each protocol supporting the given token.
Address
required
The token contract address.
Returns: Promise<ProtocolsSupplyResponse>

tokens()

Returns all supported tokens on the current chain with their metadata (address, symbol, decimals, balance, price). Returns: Promise<TokensResponse>{ tokens: TokenInfo[] }

stats()

Returns aggregate statistics for the current chain: total balance, deposits, users, transactions, APR, and liquidity distribution. Returns: Promise<Statistics>

tvl()

Returns the total value locked on the current chain. Returns: Promise<TVLResponse>{ tvl: number }

Optimizer

The optimizer provides capital allocation recommendations. See the Optimizer reference for full documentation.

optimize(options)

Computes optimal capital allocation across protocols for a given token and capital amount. Returns the allocation plan, action steps, and execution-ready calldata.

System

health()

Returns the API health status, version, and server time.

getApiConfig()

Returns the global API configuration, including minimum withdrawal thresholds, optimizer settings, and per-chain configuration.

chains()

Returns the list of supported chain IDs.

Accessors

getChain()

Returns the Chain enum value configured on this client.

getApiUrl()

Returns the resolved API base URL.

Next Steps

Agent Class

Wallet-scoped lifecycle, monitoring, and operations

Optimizer

Capital allocation optimization

Overview

SDK architecture and configuration reference

Quickstart

End-to-end integration tutorial