batchRequests

Batch multiple calls into a single RPC request

Return

batch request

Parameters

requests

list of requests to be batched together


Batch multiple calls into a single RPC request

Return

batch request

Parameters

requests

requests to be batched together

Samples

import com.swmansion.starknet.data.selectorFromName
import com.swmansion.starknet.data.types.*
import com.swmansion.starknet.provider.exceptions.RequestFailedException
import com.swmansion.starknet.provider.exceptions.RpcRequestFailedException
import com.swmansion.starknet.provider.rpc.JsonRpcProvider
import com.swmansion.starknet.service.http.HttpResponse
import com.swmansion.starknet.service.http.HttpService
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.mockito.kotlin.*
import starknet.utils.DevnetClient
import java.nio.file.Paths
fun main() { 
   //sampleStart 
   // docsStart
val blockNumber = provider.getBlockNumber().send().value
val request = provider.batchRequests(
    provider.getTransactionByBlockIdAndIndex(blockNumber, 0),
    provider.getTransaction(invokeTransactionHash),
    provider.getTransaction(declareTransactionHash),
    provider.getTransaction(deployAccountTransactionHash),

)

val response = request.send()
// docsEnd
assertEquals(response[0].getOrThrow().hash, invokeTransactionHash)
assertEquals(response[1].getOrThrow().hash, invokeTransactionHash)
assertEquals(response[2].getOrThrow().hash, declareTransactionHash)
assertEquals(response[3].getOrThrow().hash, deployAccountTransactionHash) 
   //sampleEnd
}