Hook for creating and managing an Abstract client instance.
import { useAbstractClient } from "@abstract-foundation/agw-react";
import { useAbstractClient } from "@abstract-foundation/agw-react";
export default function Example() {
const { data: abstractClient, isLoading, error } = useAbstractClient();
// Use the client to perform actions such as sending transactions or deploying contracts
async function submitTx() {
if (!abstractClient) return;
const hash = await abstractClient.sendTransaction({
to: "0x8e729E23CDc8bC21c37a73DA4bA9ebdddA3C8B6d",
data: "0x69",
});
}
// ... rest of your component ...
}
UseQueryResult<AbstractClient, Error>
.
Show properties
true
whenever the first fetch for a query is in-flight. Is the same as
isFetching && isPending
.true
if the query failed while fetching for the first time.true
if the data shown is the placeholder data.true
if the query failed while refetching.pending
. Is the same as isFetching && !isPending
.true
if the data in the cache is invalidated or if the data is older
than the given staleTime.cancelRefetch
: When set to true
, a
currently running request will be canceled before a new request is made. When
set to false, no refetch will be made if there is already a request running. Defaults to true
.pending
: if there’s no cached data and no query attempt was finished yet.
error
: if the query attempt resulted in an error. The corresponding error
property has the error received from the attempted fetch.
success
: if the query has received a response with no errors and is ready to display its data.
The corresponding data property on the query is the data received from the
successful fetch or if the query’s enabled property is set to false and has not been fetched
yet, data is the first initialData supplied to the query on initialization.
Was this page helpful?