Skip to content

getEvent

Usage

connect() must be called and WalletConnect session must be initiated before account information will be returned.

The getEvent() function returns a single event belonging to the currently selected account.

import { getEvent, Event, GetEventResponse } from '@puzzlehq/sdk-core';
import { useState } from 'react';
export const EventPage = () => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | undefined>();
const [event, setEvent] = useState<Event | undefined>();
const [totalPageCount, setTotalPageCount] = useState(0);
const onClick = async () => {
setLoading(true);
setError(undefined);
try {
const response: GetEventResponse = await getEvent({
id: "6569ee9d75d4cff690f8931b"
address: "aleo1t5ympyhrn6rgk7d0h0ktvmvzlymsnwg6w0c0ns5nac7s8d39x5qqtlaynz"
});
setEvent(response.event);
} catch (e) {
setError((e as Error).message);
} finally {
setLoading(false);
}
}
return (
<div>
<button
onClick={ onClick }
disabled={ loading }
>
fetch events
</button>
{ event && (
<div>
<p>{event._id}</p>
<p>{event.status}</p>
<p>{event.transactionId}</p>
<p>{event.programId}</p>
<p>{event.funcitonId}</p>
</div>
)}
{ error && <p>error connecting: {error}</p> }
</div>
);
}

Types

type GetEventRequest = {
id: string // obtained from getEvents(), requestCreateEvent(), useEvents(), or useRequestCreateEvent()
}
type GetEventResponse = {
event?: Event;
error?: string;
};

Additional related types can be found on the events page.