estimateFeeV3

Estimate fee for a call as a version 3 invoke transaction.

Estimate fee for a signed call on Starknet.

Return

Field value representing estimated fee.

Parameters

call

a call used to estimate a fee.


open override fun estimateFeeV3(call: Call, skipValidate: Boolean): Request<EstimateFeeResponseList>

Estimate fee for a call as a version 3 invoke transaction.

Estimate fee for a signed call on Starknet.

Return

Field value representing estimated fee.

Parameters

call

a call used to estimate a fee.

skipValidate

when set to true, the validation part of the transaction is skipped.


open override fun estimateFeeV3(call: Call, blockTag: BlockTag): Request<EstimateFeeResponseList>

Estimate fee for a call as a version 3 invoke transaction.

Estimate fee for a signed call on Starknet for specified block tag.

Return

Field value representing estimated fee.

Parameters

call

a call used to estimate a fee.

blockTag

a tag of the block in respect to what the query will be made.


open override fun estimateFeeV3(call: Call, blockTag: BlockTag, skipValidate: Boolean): Request<EstimateFeeResponseList>

Estimate fee for a call as a version 3 invoke transaction.

Estimate fee for a signed call on Starknet for specified block tag.

Return

Field value representing estimated fee.

Parameters

call

a call used to estimate a fee.

blockTag

a tag of the block in respect to what the query will be made.

skipValidate

when set to true, the validation part of the transaction is skipped.


Estimate fee for a list of calls as a version 3 invoke transaction.

Estimate fee for a signed list of calls on Starknet.

Return

estimated fee as field value.

Parameters

calls

a list of calls used to estimate a fee.


open override fun estimateFeeV3(calls: List<Call>, skipValidate: Boolean): Request<EstimateFeeResponseList>

Samples

import com.swmansion.starknet.account.Account
import com.swmansion.starknet.account.StandardAccount
import com.swmansion.starknet.crypto.HashMethod
import com.swmansion.starknet.crypto.StarknetCurve
import com.swmansion.starknet.data.ContractAddressCalculator
import com.swmansion.starknet.data.selectorFromName
import com.swmansion.starknet.data.types.*
import com.swmansion.starknet.extensions.toFelt
import com.swmansion.starknet.helpers.getHashMethodFromStarknetVersion
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 com.swmansion.starknet.signer.Signer
import com.swmansion.starknet.signer.StarkCurveSigner
import network.account.AccountTest.Companion.standardAccount
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import org.mockito.kotlin.any
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import starknet.data.loadTypedData
import starknet.utils.DevnetClient
import starknet.utils.ScarbClient
import java.math.BigInteger
import java.nio.file.Path
import java.nio.file.Paths
import java.time.Duration
import java.time.Instant
import kotlin.io.path.readText
fun main() { 
   //sampleStart 
   // docsStart
val call = Call(balanceContractAddress, "increase_balance", listOf(Felt(10)))

val request = account.estimateFeeV3(
    listOf(call),
    skipValidate = false,
)
val feeEstimate = request.send().values.first()
// docsEnd
assertNotEquals(Felt.ZERO, feeEstimate.overallFee)
val calculatedFee = feeEstimate.l1GasPrice.value * feeEstimate.l1GasConsumed.value + feeEstimate.l1DataGasPrice.value * feeEstimate.l1DataGasConsumed.value + feeEstimate.l2GasPrice.value * feeEstimate.l2GasConsumed.value
assertEquals(
    calculatedFee,
    feeEstimate.overallFee.value,
) 
   //sampleEnd
}

open override fun estimateFeeV3(calls: List<Call>, blockTag: BlockTag): Request<EstimateFeeResponseList>

Estimate fee for a list of calls.

Estimate fee for a signed list of calls on Starknet.

Return

estimated fee as field value.

Parameters

calls

a list of calls used to estimate a fee.

blockTag

a tag of the block in respect to what the query will be made.


open override fun estimateFeeV3(calls: List<Call>, blockTag: BlockTag, skipValidate: Boolean): Request<EstimateFeeResponseList>

Estimate fee for a list of calls.

Estimate fee for a signed list of calls on Starknet.

Return

estimated fee as field value.

Parameters

calls

a list of calls used to estimate a fee.

blockTag

a tag of the block in respect to what the query will be made.

skipValidate

when set to true, the validation part of the transaction is skipped.