1
1
// web3swift
2
- //
2
+ //
3
3
// Created by Alex Vlasov.
4
4
// Copyright © 2018 Alex Vlasov. All rights reserved.
5
- //
5
+ //
6
6
7
7
import Foundation
8
8
import BigInt
@@ -11,12 +11,12 @@ extension web3.Eth {
11
11
12
12
/// Send an EthereumTransaction object to the network. Transaction is either signed locally if there is a KeystoreManager
13
13
/// object bound to the web3 instance, or sent unsigned to the node. For local signing the password is required.
14
- ///
14
+ ///
15
15
/// "options" object can override the "to", "gasPrice", "gasLimit" and "value" parameters is pre-formed transaction.
16
16
/// "from" field in "options" is mandatory for both local and remote signing.
17
- ///
17
+ ///
18
18
/// This function is synchronous!
19
- ///
19
+ ///
20
20
/// Returns the Result object that indicates either success of failure.
21
21
public func sendTransaction( _ transaction: EthereumTransaction , transactionOptions: TransactionOptions , password: String = " web3swift " ) throws -> TransactionSendingResult {
22
22
let result = try self . sendTransactionPromise ( transaction, transactionOptions: transactionOptions, password: password) . wait ( )
@@ -27,78 +27,78 @@ extension web3.Eth {
27
27
/// Does NOT decode the data returned from the smart-contract.
28
28
/// "options" object can override the "to", "gasPrice", "gasLimit" and "value" parameters is pre-formed transaction.
29
29
/// "from" field in "options" is mandatory for both local and remote signing.
30
- ///
30
+ ///
31
31
/// "onString" field determines if value is returned based on the state of a blockchain on the latest mined block ("latest")
32
32
/// or the expected state after all the transactions in memory pool are applied ("pending").
33
- ///
33
+ ///
34
34
/// This function is synchronous!
35
- ///
35
+ ///
36
36
/// Returns the Result object that indicates either success of failure.
37
37
func call( _ transaction: EthereumTransaction , transactionOptions: TransactionOptions ) throws -> Data {
38
38
let result = try self . callPromise ( transaction, transactionOptions: transactionOptions) . wait ( )
39
39
return result
40
40
}
41
41
42
42
/// Send raw Ethereum transaction data to the network.
43
- ///
43
+ ///
44
44
/// This function is synchronous!
45
- ///
45
+ ///
46
46
/// Returns the Result object that indicates either success of failure.
47
47
public func sendRawTransaction( _ transaction: Data ) throws -> TransactionSendingResult {
48
48
let result = try self . sendRawTransactionPromise ( transaction) . wait ( )
49
49
return result
50
50
}
51
51
52
52
/// Send raw Ethereum transaction data to the network by first serializing the EthereumTransaction object.
53
- ///
53
+ ///
54
54
/// This function is synchronous!
55
- ///
55
+ ///
56
56
/// Returns the Result object that indicates either success of failure.
57
57
public func sendRawTransaction( _ transaction: EthereumTransaction ) throws -> TransactionSendingResult {
58
58
let result = try self . sendRawTransactionPromise ( transaction) . wait ( )
59
59
return result
60
60
}
61
61
62
62
/// Returns a total number of transactions sent by the particular Ethereum address.
63
- ///
63
+ ///
64
64
/// "onBlock" field determines if value is returned based on the state of a blockchain on the latest mined block ("latest")
65
65
/// or the expected state after all the transactions in memory pool are applied ("pending").
66
- ///
66
+ ///
67
67
/// This function is synchronous!
68
- ///
68
+ ///
69
69
/// Returns the Result object that indicates either success of failure.
70
70
public func getTransactionCount( address: EthereumAddress , onBlock: String = " latest " ) throws -> BigUInt {
71
71
let result = try self . getTransactionCountPromise ( address: address, onBlock: onBlock) . wait ( )
72
72
return result
73
73
}
74
74
75
75
/// Returns a balance of particular Ethereum address in Wei units (1 ETH = 10^18 Wei).
76
- ///
76
+ ///
77
77
/// "onString" field determines if value is returned based on the state of a blockchain on the latest mined block ("latest")
78
78
/// or the expected state after all the transactions in memory pool are applied ("pending").
79
- ///
79
+ ///
80
80
/// This function is synchronous!
81
- ///
81
+ ///
82
82
/// Returns the Result object that indicates either success of failure.
83
83
public func getBalance( address: EthereumAddress , onBlock: String = " latest " ) throws -> BigUInt {
84
84
let result = try self . getBalancePromise ( address: address, onBlock: onBlock) . wait ( )
85
85
return result
86
86
}
87
87
88
88
/// Returns a block number of the last mined block that Ethereum node knows about.
89
- ///
89
+ ///
90
90
/// This function is synchronous!
91
- ///
91
+ ///
92
92
/// Returns the Result object that indicates either success of failure.
93
93
public func getBlockNumber( ) throws -> BigUInt {
94
94
let result = try self . getBlockNumberPromise ( ) . wait ( )
95
95
return result
96
96
}
97
97
98
98
/// Returns a current gas price in the units of Wei. The node has internal algorithms for averaging over the last few blocks.
99
- ///
99
+ ///
100
100
/// This function is synchronous!
101
- ///
101
+ ///
102
102
/// Returns the Result object that indicates either success of failure.
103
103
public func getGasPrice( ) throws -> BigUInt {
104
104
let result = try self . getGasPricePromise ( ) . wait ( )
@@ -107,9 +107,9 @@ extension web3.Eth {
107
107
108
108
/// Returns transaction details for particular transaction hash. Details indicate position of the transaction in a particular block,
109
109
/// as well as original transaction details such as value, gas limit, gas price, etc.
110
- ///
110
+ ///
111
111
/// This function is synchronous!
112
- ///
112
+ ///
113
113
/// Returns the Result object that indicates either success of failure.
114
114
public func getTransactionDetails( _ txhash: Data ) throws -> TransactionDetails {
115
115
let result = try self . getTransactionDetailsPromise ( txhash) . wait ( )
@@ -118,9 +118,9 @@ extension web3.Eth {
118
118
119
119
/// Returns transaction details for particular transaction hash. Details indicate position of the transaction in a particular block,
120
120
/// as well as original transaction details such as value, gas limit, gas price, etc.
121
- ///
121
+ ///
122
122
/// This function is synchronous!
123
- ///
123
+ ///
124
124
/// Returns the Result object that indicates either success of failure.
125
125
public func getTransactionDetails( _ txhash: String ) throws -> TransactionDetails {
126
126
let result = try self . getTransactionDetailsPromise ( txhash) . wait ( )
@@ -129,9 +129,9 @@ extension web3.Eth {
129
129
130
130
/// Returns transaction receipt for particular transaction hash. Receipt indicate what has happened when the transaction
131
131
/// was included in block, so it contains logs and status, such as succesful or failed transaction.
132
- ///
132
+ ///
133
133
/// This function is synchronous!
134
- ///
134
+ ///
135
135
/// Returns the Result object that indicates either success of failure.
136
136
public func getTransactionReceipt( _ txhash: Data ) throws -> TransactionReceipt {
137
137
let result = try self . getTransactionReceiptPromise ( txhash) . wait ( )
@@ -140,9 +140,9 @@ extension web3.Eth {
140
140
141
141
/// Returns transaction receipt for particular transaction hash. Receipt indicate what has happened when the transaction
142
142
/// was included in block, so it contains logs and status, such as succesful or failed transaction.
143
- ///
143
+ ///
144
144
/// This function is synchronous!
145
- ///
145
+ ///
146
146
/// Returns the Result object that indicates either success of failure.
147
147
public func getTransactionReceipt( _ txhash: String ) throws -> TransactionReceipt {
148
148
let result = try self . getTransactionReceiptPromise ( txhash) . wait ( )
@@ -152,12 +152,12 @@ extension web3.Eth {
152
152
/// Estimates a minimal amount of gas required to run a transaction. To do it the Ethereum node tries to run it and counts
153
153
/// how much gas it consumes for computations. Setting the transaction gas limit lower than the estimate will most likely
154
154
/// result in a failing transaction.
155
- ///
155
+ ///
156
156
/// "onString" field determines if value is returned based on the state of a blockchain on the latest mined block ("latest")
157
157
/// or the expected state after all the transactions in memory pool are applied ("pending").
158
- ///
158
+ ///
159
159
/// This function is synchronous!
160
- ///
160
+ ///
161
161
/// Returns the Result object that indicates either success of failure.
162
162
/// Error can also indicate that transaction is invalid in the current state, so formally it's gas limit is infinite.
163
163
/// An example of such transaction can be sending an amount of ETH that is larger than the current account balance.
@@ -168,9 +168,9 @@ extension web3.Eth {
168
168
169
169
/// Get a list of Ethereum accounts that a node knows about.
170
170
/// If one has attached a Keystore Manager to the web3 object it returns accounts known to the keystore.
171
- ///
171
+ ///
172
172
/// This function is synchronous!
173
- ///
173
+ ///
174
174
/// Returns the Result object that indicates either success of failure.
175
175
public func getAccounts( ) throws -> [ EthereumAddress ] {
176
176
let result = try self . getAccountsPromise ( ) . wait ( )
@@ -180,9 +180,9 @@ extension web3.Eth {
180
180
/// Get information about the particular block in Ethereum network. If "fullTransactions" parameter is set to "true"
181
181
/// this call fill do a virtual join and fetch not just transaction hashes from this block,
182
182
/// but full decoded EthereumTransaction objects.
183
- ///
183
+ ///
184
184
/// This function is synchronous!
185
- ///
185
+ ///
186
186
/// Returns the Result object that indicates either success of failure.
187
187
public func getBlockByHash( _ hash: String , fullTransactions: Bool = false ) throws -> Block {
188
188
let result = try self . getBlockByHashPromise ( hash, fullTransactions: fullTransactions) . wait ( )
@@ -192,9 +192,9 @@ extension web3.Eth {
192
192
/// Get information about the particular block in Ethereum network. If "fullTransactions" parameter is set to "true"
193
193
/// this call fill do a virtual join and fetch not just transaction hashes from this block,
194
194
/// but full decoded EthereumTransaction objects.
195
- ///
195
+ ///
196
196
/// This function is synchronous!
197
- ///
197
+ ///
198
198
/// Returns the Result object that indicates either success of failure.
199
199
public func getBlockByHash( _ hash: Data , fullTransactions: Bool = false ) throws -> Block {
200
200
let result = try self . getBlockByHashPromise ( hash, fullTransactions: fullTransactions) . wait ( )
@@ -204,9 +204,9 @@ extension web3.Eth {
204
204
/// Get information about the particular block in Ethereum network. If "fullTransactions" parameter is set to "true"
205
205
/// this call fill do a virtual join and fetch not just transaction hashes from this block,
206
206
/// but full decoded EthereumTransaction objects.
207
- ///
207
+ ///
208
208
/// This function is synchronous!
209
- ///
209
+ ///
210
210
/// Returns the Result object that indicates either success of failure.
211
211
public func getBlockByNumber( _ number: UInt64 , fullTransactions: Bool = false ) throws -> Block {
212
212
let result = try self . getBlockByNumberPromise ( number, fullTransactions: fullTransactions) . wait ( )
@@ -216,9 +216,9 @@ extension web3.Eth {
216
216
/// Get information about the particular block in Ethereum network. If "fullTransactions" parameter is set to "true"
217
217
/// this call fill do a virtual join and fetch not just transaction hashes from this block,
218
218
/// but full decoded EthereumTransaction objects.
219
- ///
219
+ ///
220
220
/// This function is synchronous!
221
- ///
221
+ ///
222
222
/// Returns the Result object that indicates either success of failure.
223
223
public func getBlockByNumber( _ number: BigUInt , fullTransactions: Bool = false ) throws -> Block {
224
224
let result = try self . getBlockByNumberPromise ( number, fullTransactions: fullTransactions) . wait ( )
@@ -228,10 +228,10 @@ extension web3.Eth {
228
228
/// Get information about the particular block in Ethereum network. If "fullTransactions" parameter is set to "true"
229
229
/// this call fill do a virtual join and fetch not just transaction hashes from this block,
230
230
/// but full decoded EthereumTransaction objects.
231
- ///
231
+ ///
232
232
/// This function is synchronous!
233
- ///
234
- ///
233
+ ///
234
+ ///
235
235
public func getBlockByNumber( _ block: String , fullTransactions: Bool = false ) throws -> Block {
236
236
let result = try self . getBlockByNumberPromise ( block, fullTransactions: fullTransactions) . wait ( )
237
237
return result
0 commit comments