Geth
in EthereumKit communicates with Ethereum via JSONRPC. It connects to Ropsten
for test network and Mainnet
for main network. (Will support localhost soon
Returns the current price per gas in wei.
none
QUANTITY
- integer of the current gas price in wei.
let geth = Geth(network: .test)
geth.getGasPrice() { result in
// do something...
}
Return a balance of specified address based on the BlockParameter
.
address
- the Address you want to get a balance of.blockParameter
: based on what block parameter you want to see a balance. default islatest
. see the default block parameter.
Balance
of specified address.
let geth = Geth(network: .test)
geth.getAccount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
Returns a balance of specified address and map it to Account
model.
address
- the Address you want to get a balance of.blockParameter
: based on what block parameter you want to see a balance. default islatest
. see the default block parameter.
Account
of specified address.
let geth = Geth(network: .test)
geth.getAccount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
Returns a number of transactions that a specified address has.
address
- the Address you want to get a balance of.blockParameter
: based on what block parameter you want to see a balance. default islatest
. see the default block parameter.
A number of transactions the specified address has.
let geth = Geth(network: .test)
geth.getTransactionCount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
Creates new message call transaction or a contract creation for signed transactions.
data
- The signed transaction data.
DATA, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use GetTransactionReceipt
to get the contract address, after the transaction was mined, when you created a contract.
Executes a new message call immediately without creating a transaction on the block chain.
from
- (Optional) the Address the transaction is sent from.to
- the address the transaction is directed to.gas
- (Optional) integer of the gas provided for the transaction execution.gasPrice
- (Optional) integer of the gasPrice used for each paid gas.value
- (Optional) integer of the value send with this transaction.data
- (Optional) hash of the method signature and encoded parameters.blockParameter
- integer block number, or the specific string. default islatest
. see the default block parameter.
data
- the return value of executed contract.
let geth = Geth(network: .test)
geth.call(to: "0xf204a4ef082f5c04bb89f7d5e6568b796096735a", data: "0x70a0823100000000000000000000000091c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F", blockParameter: .latest) { result in
// do something...
}
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.
from
- (Optional) the Address the transaction is sent from.to
- the address the transaction is directed to.gas
- (Optional) integer of the gas provided for the transaction execution.gasPrice
- (Optional) integer of the gasPrice used for each paid gas.value
- (Optional) integer of the value send with this transaction.data
- (Optional) hash of the method signature and encoded parameters.
QUANTITY - the amount of gas used.
let geth = Geth(network: .test)
geth.getEstimateGas(to: address) { result in
// Do something
}
Returns the number of most recent block.
none
QUANTITY - integer of the current block number the client is on.
let geth = Geth(configuration: configuration)
geth.getBlockNumber { result in
// Do something
}