viem-goviem-go

waitForCallsStatus

Waits for call batch status (EIP-5792)

Import

Import the wallet actions package so you can call this action.

import "github.com/ChefBingbong/viem-go/actions/wallet"

Usage

See how to construct a wallet client and call this action.

import (
"context"
"log"
"github.com/ChefBingbong/viem-go/actions/wallet"
"github.com/ChefBingbong/viem-go/client"
"github.com/ChefBingbong/viem-go/client/transport"
"github.com/ChefBingbong/viem-go/chain/definitions"
)
ctx := context.Background()
walletClient, err := client.CreateWalletClient(client.WalletClientConfig{
Chain: definitions.Mainnet,
Transport: transport.HTTP("https://eth.llamarpc.com"),
})
if err != nil {
log.Fatal(err)
}
defer func() { _ = walletClient.Close() }()
status, err := wallet.WaitForCallsStatus(ctx, walletClient, wallet.WaitForCallsStatusParameters{
ID: "0xdeadbeef",
})
if err != nil {
log.Fatal(err)
}
log.Printf("Status: %s (code: %d)", status.Status, status.StatusCode)

Returns

*GetCallsStatusReturnType

The call status with receipts after the calls are included in a block or the status check function returns true.

Parameters

ID

Specify which call bundle to wait for.

  • Type: string

  • Required

The identifier of the call batch to wait for (returned from sendCalls).

status, err := wallet.WaitForCallsStatus(ctx, walletClient, wallet.WaitForCallsStatusParameters{
ID: "0xdeadbeef",
})

PollingInterval

Control how frequently the call status is polled.

  • Type: time.Duration

  • Default: client.PollingInterval()

  • Optional

The polling frequency.

import "time"
status, err := wallet.WaitForCallsStatus(ctx, walletClient, wallet.WaitForCallsStatusParameters{
ID: "0xdeadbeef",
PollingInterval: 1 * time.Second,
})

Status

Provide a custom function to decide when polling should stop.

  • Type: func(*GetCallsStatusReturnType) bool

  • Default: statusCode == 200 || statusCode >= 300

  • Optional

A function that determines whether to stop polling based on the status.

status, err := wallet.WaitForCallsStatus(ctx, walletClient, wallet.WaitForCallsStatusParameters{
ID: "0xdeadbeef",
Status: func(result *wallet.GetCallsStatusReturnType) bool {
return result.StatusCode == 200 // Only stop on success
},
})

ThrowOnFailure

  • Type: bool

  • Default: false

  • Optional

When true, returns an error if the call bundle fails.

status, err := wallet.WaitForCallsStatus(ctx, walletClient, wallet.WaitForCallsStatusParameters{
ID: "0xdeadbeef",
ThrowOnFailure: true,
})

Timeout

  • Type: time.Duration

  • Default: 60 seconds

  • Optional

The maximum time to wait before stopping polling.

import "time"
status, err := wallet.WaitForCallsStatus(ctx, walletClient, wallet.WaitForCallsStatusParameters{
ID: "0xdeadbeef",
Timeout: 30 * time.Second,
})

RetryCount

Configure how many times to retry if the request fails.

  • Type: *int

  • Default: 4

  • Optional

The number of times to retry if the call bundle request fails.

RetryDelay

Customize the backoff strategy between retries.

  • Type: func(int) time.Duration

  • Default: Exponential backoff: (1 << count) * 200ms

  • Optional

A function that returns the delay between retries.

JSON-RPC Method