Developer Portal forAgentDAO

FundAgentData API

Complete API reference for the FundAgentData contract

Write Methods

addAdmin

Add an admin for a domain's Safe. Admins can manage the Safe's configuration and execute transactions.

Method Signature

function addAdmin(string domainName, address admin) external

Example Usage

// Example usage with validation
try {
  // Validate the admin address
  if (!ethers.isAddress(adminAddress)) {
    throw new Error("Invalid admin address")
  }

  // Check if already an admin
  const safeData = await fundAgentData.getSafeData("my-domain")
  if (safeData.admins.includes(adminAddress)) {
    throw new Error("Address is already an admin")
  }

  const tx = await fundAgentData.addAdmin("my-domain", adminAddress)
  await tx.wait()

  console.log(`Admin ${adminAddress} added to ${domainName}`)
} catch (error) {
  console.error("Error adding admin:", error)
}

Possible Errors

  • NotAuthorized: Caller is not authorized
  • DomainNotFound: The specified domain does not exist
  • InvalidAddress: The provided address is invalid

registerSafe

Register a new Safe for a domain. This should be called after creating a Safe with FundAgent.

Method Signature

function registerSafe(string domainName, address safe, string version, address[] owners, uint256 threshold, address eshToken) external

Example Usage

// Example usage with error handling
import { SafeRegistrationResult } from "./types"

try {
  // First create the Safe using FundAgent
  const safe = await fundAgent.createDomainSafe(
    "my-domain",
    ["0x123...", "0x456..."],
    2,
    eshTokenAddress
  )

  // Then register it in FundAgentData
  const tx = await fundAgentData.registerSafe(
    "my-domain",
    safe.safeAddress,
    "1.3.0",
    ["0x123...", "0x456..."],
    2,
    eshTokenAddress
  )
  await tx.wait()

  // Get the registered Safe data
  const safeData = await fundAgentData.getSafeData("my-domain")
  console.log("Safe registered:", safeData)
} catch (error) {
  if (error.message.includes("DomainNotFound")) {
    console.error("Domain does not exist")
  } else if (error.message.includes("SafeAlreadyRegistered")) {
    console.error("Safe already registered for this domain")
  } else {
    console.error("Error registering Safe:", error)
  }
}

Possible Errors

  • DomainNotFound: The specified domain does not exist
  • SafeAlreadyRegistered: Safe is already registered for this domain
  • InvalidOwners: Owner array is empty or contains invalid addresses
  • InvalidThreshold: Threshold must be > 0 and <= number of owners

removeAdmin

Remove an admin from a domain's Safe

Method Signature

function removeAdmin(string domainName, address admin) external

Example Usage

// Example usage
const tx = await fundAgentData.removeAdmin(
  "my-domain",
  adminAddress
)

Possible Errors

  • NotAuthorized: Caller is not authorized
  • DomainNotFound: The specified domain does not exist

renounceOwnership

Renounce ownership of the contract

Method Signature

function renounceOwnership() external

Example Usage

// Example usage
const tx = await fundAgentData.renounceOwnership()

Possible Errors

  • NotAuthorized: Caller is not the current owner

setHistoryBot

Set the HistoryBot contract address

Method Signature

function setHistoryBot(address _historyBot) external

Example Usage

// Example usage
const tx = await fundAgentData.setHistoryBot(historyBotAddress)

Possible Errors

  • NotAuthorized: Caller is not the owner

transferOwnership

Transfer ownership of the contract to a new address

Method Signature

function transferOwnership(address newOwner) external

Example Usage

// Example usage
const tx = await fundAgentData.transferOwnership(newOwnerAddress)

Possible Errors

  • NotAuthorized: Caller is not the current owner