sendCallsSync
Sends a batch of calls synchronously (EIP-5792)
Sends a batch of calls synchronously (EIP-5792)
Import the wallet actions package so you can call this action synchronously.
import "github.com/ChefBingbong/viem-go/actions/wallet"See how to construct a wallet client and call this action.
import ( "context" "log" "math/big"
"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.SendCallsSync(ctx, walletClient, wallet.SendCallsSyncParameters{ SendCallsParameters: wallet.SendCallsParameters{ Calls: []wallet.Call{ {Data: "0xdeadbeef", To: "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"}, {To: "0x70997970c51812dc3a010c7d01b50e0d17dc79c8", Value: big.NewInt(69420)}, }, },})if err != nil { log.Fatal(err)}log.Printf("Call status: %+v", status)*GetCallsStatusReturnType
The call status with receipts after the calls are included in a block.
All parameters from sendCalls are supported, plus:
Control how frequently the call status is polled.
Type: time.Duration
Default: client.PollingInterval()
Optional
The polling interval to poll for the calls status.
import "time"
status, err := wallet.SendCallsSync(ctx, walletClient, wallet.SendCallsSyncParameters{ SendCallsParameters: wallet.SendCallsParameters{Calls: []wallet.Call{...}}, PollingInterval: 1 * time.Second,})Provide a custom function to decide when polling should stop.
func(*GetCallsStatusReturnType) boolstatusCode == 200 || statusCode >= 300A function that determines whether to stop polling.
status, err := wallet.SendCallsSync(ctx, walletClient, wallet.SendCallsSyncParameters{ SendCallsParameters: wallet.SendCallsParameters{Calls: []wallet.Call{...}}, Status: func(result *wallet.GetCallsStatusReturnType) bool { return result.StatusCode == 200 // Only stop on success },})Type: bool
Default: false
Optional
When true, returns an error if the call bundle fails.
status, err := wallet.SendCallsSync(ctx, walletClient, wallet.SendCallsSyncParameters{ SendCallsParameters: wallet.SendCallsParameters{Calls: []wallet.Call{...}}, ThrowOnFailure: true,})Type: *time.Duration
Default: max(chain.blockTime * 3, 5000ms)
Optional
The timeout (in milliseconds) to wait for calls to be included in a block.
import "time"
timeout := 20 * time.Secondstatus, err := wallet.SendCallsSync(ctx, walletClient, wallet.SendCallsSyncParameters{ SendCallsParameters: wallet.SendCallsParameters{Calls: []wallet.Call{...}}, Timeout: &timeout,})wallet_sendCalls (EIP-5792)wallet_getCallsStatus (EIP-5792) — polled repeatedly