Overview
This guide will get you up and running with the Giza Agent SDK. You’ll create a smart account, activate an agent, and start optimizing yield automatically.This quickstart focuses on the Agentic integration. For IaaS (Intelligence as a Service) using the Optimizer only, see the IaaS Integration Guide.
Architecture
Prerequisites
Node.js 18+
Node.js 18+
Check your version:
node --versionDownload from nodejs.org if needed.TypeScript Project
TypeScript Project
The SDK is built for TypeScript. JavaScript works too, but you’ll miss out on type safety.
Giza API Credentials
Giza API Credentials
You’ll need:
GIZA_API_KEY- Your partner API keyGIZA_API_URL- Giza backend URLGIZA_PARTNER_NAME- Your partner identifier
Get API Keys
Contact Giza to obtain your credentials
Installation
Environment Setup
Create a.env file in your project root:
.env
Complete Integration Flow
Step 1: Initialize the SDK
Step 2: Create a Smart Account
Generate a smart account for your user. This is where they’ll deposit funds.Step 3: Get Available Protocols
Check which DeFi protocols are available for the token you want to optimize:Step 4: User Deposits Funds
1
User sends tokens to smart account
User transfers USDC (or supported token) to the
smartAccountAddress from Step 2.2
Wait for confirmation
Wait for the transaction to be confirmed on-chain.
Step 5: Activate the Agent
After the user deposits, activate the agent to start optimization:Once activated, the agent automatically:
- Monitors APRs across selected protocols
- Rebalances capital for optimal yield
- Handles all gas costs internally
- Continues optimizing until deactivated
Step 6: Monitor Performance
Track the agent’s performance:Step 7: Withdraw Funds
Users can withdraw partially or fully at any time:- Full Withdrawal
- Partial Withdrawal
Additional Operations
Top-Up Active Agent
Update Protocols
Manual Rebalance
Error Handling
Always wrap SDK calls in try-catch blocks:Error Handling Guide
Learn about error types and handling strategies
Troubleshooting
Environment variables not found
Environment variables not found
Make sure:
.envfile exists in project root- You’re loading it (e.g.,
dotenvpackage) - Variable names match exactly:
GIZA_API_KEY,GIZA_API_URL,GIZA_PARTNER_NAME
ValidationError: invalid address
ValidationError: invalid address
Addresses must:
- Start with
0x - Be 42 characters long (0x + 40 hex chars)
- Use valid hex characters (0-9, a-f, A-F)
API returns 401 Unauthorized
API returns 401 Unauthorized
Agent activation fails
Agent activation fails
Ensure:
- Smart account has received the deposit
- Transaction hash is valid and confirmed
- Selected protocols are available for the token
- Token address is correct for the chain
Full Troubleshooting Guide
See common issues and solutions