Skip to content

Commit 0a70a0f

Browse files
committed
feat: Add EIP-7702 authorization list support to Transaction
1 parent 6791829 commit 0a70a0f

File tree

7 files changed

+643
-51
lines changed

7 files changed

+643
-51
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*
2+
* Copyright 2026 Web3 Labs Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package org.web3j.protocol.core.methods.response;
14+
15+
import java.math.BigInteger;
16+
import java.util.Objects;
17+
18+
import com.fasterxml.jackson.annotation.JsonProperty;
19+
20+
import org.web3j.utils.Numeric;
21+
22+
/** EIP-7702 authorization tuple returned in transaction responses. */
23+
public class AuthorizationTuple {
24+
private String chainId;
25+
26+
private String address;
27+
28+
private String nonce;
29+
30+
@JsonProperty("yParity")
31+
private String yParity;
32+
33+
private String r;
34+
35+
private String s;
36+
37+
public AuthorizationTuple() {}
38+
39+
public AuthorizationTuple(
40+
String chainId, String address, String nonce, String yParity, String r, String s) {
41+
this.chainId = chainId;
42+
this.address = address;
43+
this.nonce = nonce;
44+
this.yParity = yParity;
45+
this.r = r;
46+
this.s = s;
47+
}
48+
49+
public BigInteger getChainId() {
50+
return chainId != null ? Numeric.decodeQuantity(chainId) : null;
51+
}
52+
53+
public String getChainIdRaw() {
54+
return chainId;
55+
}
56+
57+
public void setChainId(String chainId) {
58+
this.chainId = chainId;
59+
}
60+
61+
public String getAddress() {
62+
return address;
63+
}
64+
65+
public void setAddress(String address) {
66+
this.address = address;
67+
}
68+
69+
public BigInteger getNonce() {
70+
return nonce != null ? Numeric.decodeQuantity(nonce) : null;
71+
}
72+
73+
public String getNonceRaw() {
74+
return nonce;
75+
}
76+
77+
public void setNonce(String nonce) {
78+
this.nonce = nonce;
79+
}
80+
81+
public BigInteger getYParity() {
82+
return yParity != null ? Numeric.decodeQuantity(yParity) : null;
83+
}
84+
85+
public String getYParityRaw() {
86+
return yParity;
87+
}
88+
89+
public void setYParity(String yParity) {
90+
this.yParity = yParity;
91+
}
92+
93+
public BigInteger getR() {
94+
return r != null ? Numeric.decodeQuantity(r) : null;
95+
}
96+
97+
public String getRRaw() {
98+
return r;
99+
}
100+
101+
public void setR(String r) {
102+
this.r = r;
103+
}
104+
105+
public BigInteger getS() {
106+
return s != null ? Numeric.decodeQuantity(s) : null;
107+
}
108+
109+
public String getSRaw() {
110+
return s;
111+
}
112+
113+
public void setS(String s) {
114+
this.s = s;
115+
}
116+
117+
@Override
118+
public boolean equals(Object o) {
119+
if (this == o) return true;
120+
if (o == null || getClass() != o.getClass()) return false;
121+
AuthorizationTuple that = (AuthorizationTuple) o;
122+
return Objects.equals(chainId, that.chainId)
123+
&& Objects.equals(address, that.address)
124+
&& Objects.equals(nonce, that.nonce)
125+
&& Objects.equals(yParity, that.yParity)
126+
&& Objects.equals(r, that.r)
127+
&& Objects.equals(s, that.s);
128+
}
129+
130+
@Override
131+
public int hashCode() {
132+
return Objects.hash(chainId, address, nonce, yParity, r, s);
133+
}
134+
}

core/src/main/java/org/web3j/protocol/core/methods/response/EthBlock.java

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ public TransactionObject(
763763
nonce,
764764
blockHash,
765765
blockNumber,
766+
null,
766767
transactionIndex,
767768
from,
768769
to,
@@ -776,10 +777,66 @@ public TransactionObject(
776777
r,
777778
s,
778779
v,
780+
null,
779781
type,
780782
maxFeePerGas,
781783
maxPriorityFeePerGas,
782-
accessList);
784+
accessList,
785+
null,
786+
null,
787+
null);
788+
}
789+
790+
public TransactionObject(
791+
String hash,
792+
String nonce,
793+
String blockHash,
794+
String blockNumber,
795+
String transactionIndex,
796+
String from,
797+
String to,
798+
String value,
799+
String gas,
800+
String gasPrice,
801+
String input,
802+
String creates,
803+
String publicKey,
804+
String raw,
805+
String r,
806+
String s,
807+
long v,
808+
String type,
809+
String maxFeePerGas,
810+
String maxPriorityFeePerGas,
811+
List<AccessListObject> accessList,
812+
List<AuthorizationTuple> authorizationList) {
813+
super(
814+
hash,
815+
nonce,
816+
blockHash,
817+
blockNumber,
818+
null,
819+
transactionIndex,
820+
from,
821+
to,
822+
value,
823+
gas,
824+
gasPrice,
825+
input,
826+
creates,
827+
publicKey,
828+
raw,
829+
r,
830+
s,
831+
v,
832+
null,
833+
type,
834+
maxFeePerGas,
835+
maxPriorityFeePerGas,
836+
accessList,
837+
null,
838+
null,
839+
authorizationList);
783840
}
784841

785842
public TransactionObject(
@@ -829,7 +886,10 @@ public TransactionObject(
829886
type,
830887
maxFeePerGas,
831888
maxPriorityFeePerGas,
832-
accessList);
889+
accessList,
890+
null,
891+
null,
892+
null);
833893
}
834894

835895
public TransactionObject(
@@ -857,7 +917,8 @@ public TransactionObject(
857917
String maxPriorityFeePerGas,
858918
List<AccessListObject> accessList,
859919
String maxFeePerBlobGas,
860-
List<String> blobVersionedHashes) {
920+
List<String> blobVersionedHashes,
921+
List<AuthorizationTuple> authorizationList) {
861922
super(
862923
hash,
863924
nonce,
@@ -883,7 +944,8 @@ public TransactionObject(
883944
maxPriorityFeePerGas,
884945
accessList,
885946
maxFeePerBlobGas,
886-
blobVersionedHashes);
947+
blobVersionedHashes,
948+
authorizationList);
887949
}
888950

889951
@Override

0 commit comments

Comments
 (0)