The AgetherClient handles agent account management: balance queries, token transfers between the EOA wallet and the Safe account smart wallet, and identity/reputation lookups.
For lending operations (deposit, borrow, repay, withdraw) and registration, use the MorphoClient instead. AgetherClient focuses on account-level operations and requires a pre-existing agentId.
Constructor
From Private Key
From Signer
import { AgetherClient, ChainId } from '@agether/sdk';
const client = AgetherClient.fromPrivateKey(
process.env.AGENT_PRIVATE_KEY!,
BigInt(17676), // Your ERC-8004 agent ID
ChainId.Base, // Or pass a full AgetherConfig object
);
import { AgetherClient, getDefaultConfig, ChainId } from '@agether/sdk';
const client = new AgetherClient({
config: getDefaultConfig(ChainId.Base),
signer: yourEthersSigner,
agentId: BigInt(17676),
});
AgetherClient requires an existing agentId. The agentId is the tokenId of your ERC-8004 NFT, assigned when you mint. Use MorphoClient.register() to create a new identity + account in one step.
Methods
Account Management
createAccount()
Deploy an Safe account smart wallet for the agent. The caller must own the ERC-8004 NFT.
const accountAddress = await client.createAccount();
console.log('Safe account deployed:', accountAddress);
getAccountAddress()
Get the Safe account address for the current agent. Cached after first call.
const address = await client.getAccountAddress();
console.log('Safe account:', address);
accountExists()
Check whether the Safe account has been deployed.
const exists = await client.accountExists();
Balances
getBalances()
Retrieve ETH and USDC balances for both the EOA wallet and the Safe account.
const balances = await client.getBalances();
console.log('EOA:');
console.log(' ETH:', balances.eoa.eth);
console.log(' USDC:', balances.eoa.usdc);
if (balances.account) {
console.log('Safe account:');
console.log(' Address:', balances.account.address);
console.log(' ETH:', balances.account.eth);
console.log(' USDC:', balances.account.usdc);
}
Return type:
{
eoa: { eth: string; usdc: string };
account?: { address: string; eth: string; usdc: string };
}
fundAccount(usdcAmount)
Transfer USDC from the EOA wallet into the Safe account.
// Send $100 USDC to Safe account
await client.fundAccount('100');
The usdcAmount is a human-readable string (e.g. '100' for $100 USDC). The SDK handles decimal conversion internally.
Identity & Validation
identityExists()
Check whether the agent’s ERC-8004 NFT exists.
const exists = await client.identityExists();
getIdentityOwner()
Get the owner address of the ERC-8004 NFT.
const owner = await client.getIdentityOwner();
isKyaRequired()
Check whether KYA validation is required for this agent.
const required = await client.isKyaRequired();
isKyaApproved()
Check whether the agent’s code has been approved via the ValidationRegistry (KYA gate).
const approved = await client.isKyaApproved();
Reputation
getCreditScore()
Read the agent’s current credit score from the Agether8004Scorer contract.
const score = await client.getCreditScore();
console.log('Credit score:', score.toString()); // Returns bigint
isScoreFresh()
Check if the score is fresh (within MAX_ORACLE_AGE).
const { fresh, age } = await client.isScoreFresh();
console.log('Fresh:', fresh, '| Age:', age.toString(), 'seconds');
isEligible(minScore?)
Check if the agent meets a minimum score threshold.
const { eligible, currentScore } = await client.isEligible(500n);
console.log('Eligible:', eligible, '| Score:', currentScore.toString());
Complete Example
import { AgetherClient, ChainId } from '@agether/sdk';
async function main() {
const client = AgetherClient.fromPrivateKey(
process.env.AGENT_PRIVATE_KEY!,
BigInt(17676),
ChainId.Base,
);
// Check balances
const balances = await client.getBalances();
console.log('EOA USDC:', balances.eoa.usdc);
if (balances.account) {
console.log('Account USDC:', balances.account.usdc);
}
// Fund the Safe account
await client.fundAccount('100');
console.log('Funded $100 USDC to Safe account');
// Check credit score
const score = await client.getCreditScore();
console.log('Credit score:', score.toString());
}
main().catch(console.error);
Always ensure your agent has enough ETH for gas on Base. Transactions will fail if the EOA balance is too low.