@@ -27,6 +27,7 @@ option java_package = "com.hedera.mirror.api.proto";
2727
2828import "services/basic_types.proto" ;
2929import "services/timestamp.proto" ;
30+ import "services/transaction.proto" ;
3031
3132/**
3233 * Request object to query an address book for its list of nodes
@@ -43,6 +44,149 @@ message AddressBookQuery {
4344 int32 limit = 2 ;
4445}
4546
47+ /**
48+ * Determines whether the fee estimation depends on network state (e.g., whether an account exists or requires creation
49+ * during a transfer).
50+ */
51+ enum EstimateMode {
52+ /*
53+ * Estimate based on intrinsic properties plus the latest known state (e.g., check if accounts
54+ * exist, load token associations). This is the default if no mode is specified.
55+ */
56+ STATE = 0 ;
57+
58+ /*
59+ * Estimate based solely on the transaction's inherent properties (e.g., size, signatures, keys). Ignores
60+ * state-dependent factors.
61+ */
62+ INTRINSIC = 1 ;
63+ }
64+
65+ /**
66+ * Request object for users, SDKs, and tools to query expected fees without
67+ * submitting transactions to the network.
68+ */
69+ message FeeEstimateQuery {
70+ /**
71+ * The mode of fee estimation. Defaults to `STATE` if omitted.
72+ */
73+ EstimateMode mode = 1 ;
74+
75+ /**
76+ * The raw HAPI transaction that should be estimated.
77+ */
78+ .proto.Transaction transaction = 2 ;
79+ }
80+
81+ /**
82+ * The response containing the estimated transaction fees.
83+ */
84+ message FeeEstimateResponse {
85+ /**
86+ * The mode that was used to calculate the fees.
87+ */
88+ EstimateMode mode = 1 ;
89+
90+ /**
91+ * The network fee component which covers the cost of gossip, consensus,
92+ * signature verifications, fee payment, and storage.
93+ */
94+ NetworkFee network = 2 ;
95+
96+ /**
97+ * The node fee component which is to be paid to the node that submitted the
98+ * transaction to the network. This fee exists to compensate the node for the
99+ * work it performed to pre-check the transaction before submitting it, and
100+ * incentivizes the node to accept new transactions from users.
101+ */
102+ FeeEstimate node = 3 ;
103+
104+ /**
105+ * An array of strings for any caveats (e.g., ["Fallback to worst-case due to missing state"]).
106+ */
107+ repeated string notes = 4 ;
108+
109+ /**
110+ * The service fee component which covers execution costs, state saved in the
111+ * Merkle tree, and additional costs to the blockchain storage.
112+ */
113+ FeeEstimate service = 5 ;
114+
115+ /**
116+ * The sum of the network, node, and service subtotals in tinycents.
117+ */
118+ uint64 total = 6 ;
119+ }
120+
121+ /**
122+ * The fee estimate for the network component. Includes the base fee and any
123+ * extras associated with it.
124+ */
125+ message FeeEstimate {
126+ /**
127+ * The base fee price, in tinycents.
128+ */
129+ uint64 base = 1 ;
130+
131+ /**
132+ * The extra fees that apply for this fee component.
133+ */
134+ repeated FeeExtra extras = 2 ;
135+ }
136+
137+ /**
138+ * The extra fee charged for the transaction.
139+ */
140+ message FeeExtra {
141+ /**
142+ * The charged count of items as calculated by `max(0, count - included)`.
143+ */
144+ uint32 charged = 1 ;
145+
146+ /**
147+ * The actual count of items received.
148+ */
149+ uint32 count = 2 ;
150+
151+ /**
152+ * The fee price per unit in tinycents.
153+ */
154+ uint64 fee_per_unit = 3 ;
155+
156+ /**
157+ * The count of this "extra" that is included for free.
158+ */
159+ uint32 included = 4 ;
160+
161+ /**
162+ * The unique name of this extra fee as defined in the fee schedule.
163+ */
164+ string name = 5 ;
165+
166+ /**
167+ * The subtotal in tinycents for this extra fee. Calculated by multiplying the
168+ * charged count by the fee_per_unit.
169+ */
170+ uint64 subtotal = 6 ;
171+ }
172+
173+ /**
174+ * The network fee component which covers the cost of gossip, consensus,
175+ * signature verifications, fee payment, and storage.
176+ */
177+ message NetworkFee {
178+ /**
179+ * Multiplied by the node fee to determine the total network fee.
180+ */
181+ uint32 multiplier = 1 ;
182+
183+ /**
184+ * The subtotal in tinycents for the network fee component which is calculated by
185+ * multiplying the node subtotal by the network multiplier.
186+ */
187+ uint64 subtotal = 2 ;
188+ }
189+
46190/**
47191 * Provides cross network APIs like address book queries
48192 */
@@ -53,5 +197,11 @@ service NetworkService {
53197 * the network since it is reconstructed from a normalized database table.
54198 */
55199 rpc getNodes (AddressBookQuery ) returns (stream .proto .NodeAddress );
200+
201+ /*
202+ * Query for fee estimates without submitting transactions to the network.
203+ * Returns a stream with a single FeeEstimateResponse.
204+ */
205+ rpc getFeeEstimate (FeeEstimateQuery ) returns (stream FeeEstimateResponse );
56206}
57207
0 commit comments