@@ -124,7 +124,6 @@ internal async Task<RpcResponseMessage> Request(RpcRequestMessage requestMessage
124
124
private async Task < RpcResponseMessage > CreateUserOpAndSend ( RpcRequestMessage requestMessage )
125
125
{
126
126
// Deserialize the transaction input from the request message
127
- Debug . Log ( "Creating UserOp..." ) ;
128
127
129
128
var paramList = JsonConvert . DeserializeObject < List < object > > ( JsonConvert . SerializeObject ( requestMessage . RawParameters ) ) ;
130
129
var transactionInput = JsonConvert . DeserializeObject < TransactionInput > ( JsonConvert . SerializeObject ( paramList [ 0 ] ) ) ;
@@ -146,7 +145,6 @@ private async Task<RpcResponseMessage> CreateUserOpAndSend(RpcRequestMessage req
146
145
var executeInput = executeFn . CreateTransactionInput ( Accounts [ 0 ] ) ;
147
146
148
147
// Create the user operation and its safe (hexified) version
149
- Debug . Log ( "Create the user operation and its safe (hexified) version..." ) ;
150
148
151
149
var partialUserOp = new EntryPointContract . UserOperation ( )
152
150
{
@@ -155,51 +153,33 @@ private async Task<RpcResponseMessage> CreateUserOpAndSend(RpcRequestMessage req
155
153
InitCode = initData . initCode ,
156
154
CallData = executeInput . Data . HexStringToByteArray ( ) ,
157
155
CallGasLimit = transactionInput . Gas . Value ,
158
- VerificationGasLimit = 150000 + initData . gas ,
159
- PreVerificationGas = 50000 ,
160
- MaxFeePerGas = latestBlock . BaseFeePerGas . Value + 2 ,
161
- MaxPriorityFeePerGas = 2 ,
156
+ VerificationGasLimit = 100000 + initData . gas ,
157
+ PreVerificationGas = 21000 ,
158
+ MaxFeePerGas = latestBlock . BaseFeePerGas . Value * 2 + BigInteger . Parse ( "1500000000" ) ,
159
+ MaxPriorityFeePerGas = BigInteger . Parse ( "1500000000" ) ,
162
160
PaymasterAndData = Constants . DUMMY_PAYMASTER_AND_DATA_HEX . HexStringToByteArray ( ) ,
163
161
Signature = dummySig ,
164
162
} ;
163
+ partialUserOp . PreVerificationGas = partialUserOp . CalcPreVerificationGas ( ) ;
165
164
var partialUserOpHexified = partialUserOp . EncodeUserOperation ( ) ;
166
165
167
166
// Update paymaster data if any
168
- Debug . Log ( "Update paymaster data if any..." ) ;
169
167
170
168
partialUserOp . PaymasterAndData = await GetPaymasterAndData ( requestMessage . Id , partialUserOpHexified ) ;
171
169
172
- partialUserOp . Signature = await partialUserOp . HashAndSignUserOp ( Config . entryPointAddress ) ;
173
- partialUserOpHexified = partialUserOp . EncodeUserOperation ( ) ;
174
-
175
- // Estimate gas with updated paymaster data
176
- Debug . Log ( "Estimate gas with updated paymaster data..." ) ;
170
+ // Hash, sign and encode the user operation
177
171
178
- var gasEstimates = await BundlerClient . EthEstimateUserOperationGas ( Config . bundlerUrl , Config . thirdwebApiKey , requestMessage . Id , partialUserOpHexified , Config . entryPointAddress ) ;
179
- partialUserOp . CallGasLimit = new HexBigInteger ( gasEstimates . CallGasLimit ) . Value ;
180
- partialUserOp . VerificationGasLimit = new HexBigInteger ( gasEstimates . VerificationGas ) . Value ;
181
- partialUserOp . PreVerificationGas = new HexBigInteger ( gasEstimates . PreVerificationGas ) . Value ;
182
-
183
- partialUserOp . Signature = await partialUserOp . HashAndSignUserOp ( Config . entryPointAddress ) ;
184
- partialUserOpHexified = partialUserOp . EncodeUserOperation ( ) ;
185
-
186
- // Update paymaster data post estimates again
187
- Debug . Log ( "Update paymaster data post estimates again..." ) ;
188
-
189
- partialUserOp . PaymasterAndData = await GetPaymasterAndData ( requestMessage . Id , partialUserOpHexified ) ;
190
172
partialUserOp . Signature = await partialUserOp . HashAndSignUserOp ( Config . entryPointAddress ) ;
191
173
partialUserOpHexified = partialUserOp . EncodeUserOperation ( ) ;
192
174
193
175
// Send the user operation
194
- Debug . Log ( "Send the user operation..." ) ;
195
176
196
177
Debug . Log ( "Valid UserOp: " + JsonConvert . SerializeObject ( partialUserOp ) ) ;
197
178
Debug . Log ( "Valid Encoded UserOp: " + JsonConvert . SerializeObject ( partialUserOpHexified ) ) ;
198
179
var userOpHash = await BundlerClient . EthSendUserOperation ( Config . bundlerUrl , Config . thirdwebApiKey , requestMessage . Id , partialUserOpHexified , Config . entryPointAddress ) ;
199
180
Debug . Log ( "UserOp Hash: " + userOpHash ) ;
200
181
201
182
// Wait for the transaction to be mined
202
- Debug . Log ( "Wait for the transaction to be mined..." ) ;
203
183
204
184
string txHash = null ;
205
185
while ( txHash == null && Application . isPlaying )
@@ -211,7 +191,6 @@ private async Task<RpcResponseMessage> CreateUserOpAndSend(RpcRequestMessage req
211
191
Debug . Log ( "Tx Hash: " + txHash ) ;
212
192
213
193
// Check if successful
214
- Debug . Log ( "Check if successful..." ) ;
215
194
216
195
var receipt = await new Web3 ( ThirdwebManager . Instance . SDK . session . RPC ) . Eth . Transactions . GetTransactionReceipt . SendRequestAsync ( txHash ) ;
217
196
var decodedEvents = receipt . DecodeAllEvents < EntryPointContract . UserOperationEventEventDTO > ( ) ;
0 commit comments