Hooks
useAns

useAns

Hook for accessing Aptos Ans data.

import { useAns } from "aptosjs"

Usage

import { useAns } from "aptosjs"
 
function App() {
  const { data, loading, error } = useAns({
    name: "gavin", 
    network: "mainnet"
  })
 
  if (loading) return <p>Loading...</p>
  if (error) return <p>Error: {error}</p>
  return <p>Addrees: {data?.address}</p>
}

Example Return

{
  address: "0x4eb1f5e767c7e760ced2cecc229a22ca4a252210d71ff0eadb23f4ee0dc23bb9"
}

Input Values

{
  address?: string, 
  name?: string, 
  network: "mainnet" | "testnet" | "devnet"
}

address (optional)

address: string 

name (optional)

name: string

network (required)

network: "mainnet" | "testnet" | "devnet"

Return Values

{
  name: string | undefined,
  address: string | undefined
}