Skip to main content

fetchEvents

function fetchEvents(
accountInfo: {
"publicKey": string;
"tokenId": string;
},
graphqlEndpoint?: string,
filterOptions?: EventActionFilterOptions): Promise<{
"blockHash": event.blockInfo.stateHash;
"blockHeight": UInt32;
"chainStatus": event.blockInfo.chainStatus;
"events": {
"data": string[];
"transactionInfo": {
"hash": string;
"memo": string;
"status": string;
};
}[];
"globalSlot": UInt32;
"parentBlockHash": event.blockInfo.parentHash;
}[]>

Asynchronously fetches event data for an account from the Mina Archive Node GraphQL API.

Parameters

accountInfo

The account information object.

accountInfo.publicKey: string

The account public key.

accountInfo.tokenId?: string

The optional token ID for the account.

graphqlEndpoint?: string= networkConfig.archiveEndpoint

The GraphQL endpoint to query. Defaults to the Archive Node GraphQL API.

filterOptions?: EventActionFilterOptions= {}

The optional filter options object.

Returns

Promise\<{ "blockHash": event.blockInfo.stateHash; "blockHeight": UInt32; "chainStatus": event.blockInfo.chainStatus; "events": { "data": string[]; "transactionInfo": { "hash": string; "memo": string; "status": string; }; }[]; "globalSlot": UInt32; "parentBlockHash": event.blockInfo.parentHash; }[]>

A promise that resolves to an array of objects containing event data, block information and transaction information for the account.

Async

Throws

If the GraphQL request fails or the response is invalid.

Example

const accountInfo = { publicKey: 'B62qiwmXrWn7Cok5VhhB3KvCwyZ7NHHstFGbiU5n7m8s2RqqNW1p1wF' };
const events = await fetchEvents(accountInfo);
console.log(events);

Source

lib/mina/fetch.ts:637