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.
import { Giza, Chain } from '@gizatech/agent-sdk';const giza = new Giza({ chain: Chain.BASE, // apiKey, partner, apiUrl fall back to env vars});
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.
When a credential is omitted from the constructor config, the SDK reads the corresponding environment variable:
Config Field
Environment Variable
Required
apiKey
GIZA_API_KEY
Yes (via config or env)
partner
GIZA_PARTNER_NAME
Yes (via config or env)
apiUrl
GIZA_API_URL
Yes (via config or env)
If neither the config field nor the environment variable is set, the constructor throws a ValidationError with a message indicating which value is missing.
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).
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.
Returns full smart-account metadata (address, backend wallet, origin wallet, chain) without creating an Agent handle. Useful when you need the raw account data.
Returns all supported tokens on the current chain with their metadata (address, symbol, decimals, balance, price).Returns:Promise<TokensResponse> — { tokens: TokenInfo[] }
Returns aggregate statistics for the current chain: total balance, deposits, users, transactions, APR, and liquidity distribution.Returns:Promise<Statistics>
Computes optimal capital allocation across protocols for a given token and capital amount. Returns the allocation plan, action steps, and execution-ready calldata.
const result = await giza.optimize({ token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', capital: '1000000000', // in token smallest unit protocols: ['aave', 'compound'], currentAllocations: { aave: '500000000', compound: '500000000' },});console.log('Optimal allocations:', result.optimization_result.allocations);