Skip to content

Call status

The two methods that follow a batch sent with Wallet.sendCalls (EIP-5792): one returns where the batch stands, the other has the wallet show it to the user.

Method JSON-RPC Returns Description
getCallsStatus wallet_getCallsStatus CallsStatus Where a batch stands, with its receipts once included.
showCallsStatus wallet_showCallsStatus void Has the wallet show the user where a batch stands.

Both take the id of the batch, the string that Wallet.sendCalls returned, and each returns an Effect<…, Method.Error, Transport>.

Returns where a batch stands, with its receipts once it is included.

import { Effect } from "effect";
import { Wallet } from "@ethect/core/rpc";
const outcome = (id: string) =>
Wallet.getCallsStatus(id).pipe(
Effect.map(({ status, receipts }) => {
if (status < 200) return "pending";
if (status < 300) return `confirmed in ${receipts.length} transaction(s)`;
return "failed";
}),
);
  • JSON-RPC: wallet_getCallsStatus
  • Parameters: id (string).
  • Returns: a CallsStatus.CallsStatus: the status code, whether the batch ran atomic, and its receipts.
  • An id the wallet does not know fails with the reason UnknownBundleId (code 5730).
  • An answer without a status, or with a receipt that has no 32-byte transactionHash, fails with a CodecError whose value is the answer.

The status is a number. EIP-5792 defines these codes:

Code Meaning
100 pending: the wallet received the batch, and it has not completed on chain
200 confirmed: the batch was included without reverts
400 failed off chain: the batch was not included, and the wallet will not retry
500 reverted: the batch reverted completely
600 partly reverted: some of the batch’s changes may be on chain

A wallet that answers in the words of EIP-5792 v1 is read too: "PENDING" is 100 and "CONFIRMED" is 200.

To wait for the outcome, repeat the call until the batch is no longer pending.

import { Effect, Schedule } from "effect";
import { Wallet } from "@ethect/core/rpc";
const settled = (id: string) =>
Wallet.getCallsStatus(id).pipe(
Effect.repeat({
until: ({ status }) => status >= 200,
schedule: Schedule.spaced("1 second"),
}),
);

Has the wallet show the user where a batch stands.

import { Effect } from "effect";
import { Wallet } from "@ethect/core/rpc";
const show = (id: string) =>
Wallet.showCallsStatus(id).pipe(
Effect.catchReason("RpcError", "UnknownBundleId", () => Effect.void),
);
  • JSON-RPC: wallet_showCallsStatus
  • Parameters: id (string).
  • Returns: nothing. Whatever the wallet answers is ignored, and the effect succeeds with void.
  • By the EIP, an id the wallet does not know is an error here too.
  • Codes come in hundreds. A wallet may answer a more specific code, and it stays in the hundred of its kind: test status >= 200 && status < 300, not status === 200.
  • No receipts is an empty list. receipts is [] when the wallet leaves it out. Once there, the receipts are in the order the transactions were included.
  • Off-spec answers are read when they are unambiguous. An id that is not a string, a missing chainId, block numbers as JSON numbers, keys set to undefined: see CallsStatus for each.
  • A receipt is a subset. It has logs, status, blockHash, blockNumber, gasUsed and transactionHash, and its logs are only those of the batch’s own calls.
  • Statuses are names. The status of a receipt decodes from "0x1" and "0x0" to "success" and "reverted". The status of the batch stays a number.
  • Atomic batches may share a receipt. When atomic is true, all the calls may be in one receipt.