FeeEstimatorService
public class FeeEstimatorService
An object allowing developers to automatically estimate the necessary fee per Operation to ensure it will be accpeted by a Baker. This avoids the need to ask users to enter a fee, which is not a very user friendly approach as most users wouldn’t know what is required.
-
The real signature is not needed for estimation, use the default “Zero Signature” instead
Declaration
Swift
public static let defaultSignature: [UInt8] -
Declaration
Swift
public static let defaultSignatureHex: String
-
The configuration object containing all the necessary settings to connect and communicate with the Tezos node
Declaration
Swift
public let config: TezosNodeClientConfig -
The
OperationServiceobject that will perform forging, parsing, signing, preapply and injections of operationsDeclaration
Swift
public let operationService: OperationService -
The
NetworkServicethat will handle the remote communication.Declaration
Swift
public let networkService: NetworkService -
Create a FeeEstimatorService that will allow developers to automatically create fees on the users behalf
Declaration
Swift
public init(config: TezosNodeClientConfig = TezosNodeClientConfig(withDefaultsForNetworkType: .mainnet), operationService: OperationService, networkService: NetworkService)Parameters
operationServiceThe
OperationServiceused to perform the forging.networkServiceThe
NetworkServicethat will handle the remote communication. -
estimate(operations:operationMetadata: constants: walletAddress: base58EncodedPublicKey: isRemote: completion: ) Pass in an array of
Operationsubclasses (useOperationFacotryto create) to have the library estimate the cost of sending the transaction. Function will use local or remote forging based off config passed in. If the supplied operations contain suggested fees (e.g. from a dApp) this function will estimate the fee and pick which ever is higherDeclaration
Swift
public func estimate(operations: [Operation], operationMetadata: OperationMetadata, constants: NetworkConstants, walletAddress: String, base58EncodedPublicKey: String, isRemote: Bool, completion: @escaping ((Result<EstimationResult, KukaiError>) -> Void))Parameters
operationsAn array of
Operationsubclasses to be estimated.operationMetadataAn
OperationMetadataobject containing necessary info about the current blockchain state.networkConstantsA
NetworkConstantsused to provide information about the current network requirements.withWalletThe
Walletobject used for signing the transaction.completionA callback containing the same operations passed in, modified to include fees.
-
Create an array of
OperationFeesfrom anOperationResponse.Declaration
Swift
public func extractFees(fromOperationResponse operationResponse: OperationResponse, originalRemoteOps: [Operation], forgedHash: String, withConstants constants: NetworkConstants, fromAddress address: String) -> [OperationFees]Parameters
fromOperationResponseThe
OperationResponseresulting from an RPC call to.../run_operation.forgedHashThe forged hash string resulting from a call to
TezosNodeClient.forge(...)Return Value
An array of
OperationFees -
Calculate the fee to add for the given amount of gas
Declaration
Swift
public static func feeForGas(_ gas: Int) -> XTZAmount -
Calculate the fee to add based on the size of the forged string
Declaration
Swift
public static func feeForStorage(_ forgedHexString: String, numberOfOperations: Int) -> XTZAmount -
Calculate the fee to add based on how many bytes of storage where needed
Declaration
Swift
public static func feeForBurn(_ burn: Int, withConstants contants: NetworkConstants) -> XTZAmount -
Declaration
Swift
public static func fee(forGasLimit gasLimit: Int, forgedHexString: String, numberOfOperations: Int) -> XTZAmount -
Declaration
Swift
public static func addGasSafetyMarginTo(gasUsed: Int) -> Int
Install in Dash