/
RawTransaction.java
84 lines (64 loc) · 2.27 KB
/
RawTransaction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package org.web3j.protocol.core.methods.request;
import java.math.BigInteger;
import org.web3j.utils.Numeric;
/**
* <p>Transaction class used for signing transactions locally.<br>
* For the specification, refer to p4 of the <a href="http://gavwood.com/paper.pdf">
* yellow paper</a>.</p>
*/
public class RawTransaction {
private BigInteger nonce;
private BigInteger gasPrice;
private BigInteger gasLimit;
private String to;
private BigInteger value;
private String data;
private RawTransaction(BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to,
BigInteger value, String data) {
this.nonce = nonce;
this.gasPrice = gasPrice;
this.gasLimit = gasLimit;
this.to = to;
this.value = value;
if (data != null) {
this.data = Numeric.cleanHexPrefix(data);
}
}
public static RawTransaction createContractTransaction(
BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, BigInteger value,
String init) {
return new RawTransaction(nonce, gasPrice, gasLimit, "", value, init);
}
public static RawTransaction createEtherTransaction(
BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to,
BigInteger value) {
return new RawTransaction(nonce, gasPrice, gasLimit, to, value, "");
}
public static RawTransaction createTransaction(
BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, String data) {
return createTransaction(nonce, gasPrice, gasLimit, to, BigInteger.ZERO, data);
}
public static RawTransaction createTransaction(
BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to,
BigInteger value, String data) {
return new RawTransaction(nonce, gasPrice, gasLimit, to, value, data);
}
public BigInteger getNonce() {
return nonce;
}
public BigInteger getGasPrice() {
return gasPrice;
}
public BigInteger getGasLimit() {
return gasLimit;
}
public String getTo() {
return to;
}
public BigInteger getValue() {
return value;
}
public String getData() {
return data;
}
}