Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Estimate gas without value #250

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions Web3Swift/GasEstimate/EthGasEstimate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,87 @@ public final class EthGasEstimate: BytesScalar {
)
}

/**
Ctor

- parameters:
- network: network to call
- senderAddress: bytes representation of a sender address
- recipientAddress: bytes representation of a recipient address
- gasEstimate: estimate of the gas to be spent
- gasPrice: price that will be paid for each unit of gas
- contractCall: encoded contract call
*/
public convenience init(
network: Network,
senderAddress: BytesScalar,
recipientAddress: BytesScalar,
gasEstimate: BytesScalar,
gasPrice: BytesScalar,
contractCall: BytesScalar
) {
self.init(
estimationProcedure: EstimateGasProcedure(
network: network,
parameters: [
"from" : BytesParameter(
bytes: senderAddress
),
"to" : BytesParameter(
bytes: recipientAddress
),
"gas" : QuantityParameter(
number: gasEstimate
),
"gasPrice" : QuantityParameter(
number: gasPrice
),
"data" : BytesParameter(
bytes: contractCall
)
]
)
)
}

/**
Ctor

- parameters:
- network: network to call
- senderAddress: bytes representation of a sender address
- recipientAddress: bytes representation of a recipient address
- gasPrice: price that will be paid for each unit of gas
- contractCall: encoded contract call
*/
public convenience init(
network: Network,
senderAddress: BytesScalar,
recipientAddress: BytesScalar,
gasPrice: BytesScalar,
contractCall: BytesScalar
) {
self.init(
estimationProcedure: EstimateGasProcedure(
network: network,
parameters: [
"from" : BytesParameter(
bytes: senderAddress
),
"to" : BytesParameter(
bytes: recipientAddress
),
"gasPrice" : QuantityParameter(
number: gasPrice
),
"data" : BytesParameter(
bytes: contractCall
)
]
)
)
}

/**
- returns:
Hexadecimal representation of an estimate value
Expand Down