Ethereum - User operations EIP-4337. All fields MUST be set as hex values. #3366
Replies: 3 comments 2 replies
-
Hi @DenisDemyanko, you can try to use java.math.BigInteger to parse the decimal string and convert to a hex string: BigInteger maxFeePerGas = new BigInteger(receivedJson.maxFeePerGas);
let input = EthereumSigningInput.with {
$0.maxFeePerGas = Data(hexString: maxFeePerGas.toString(16))!
// ...
}; |
Beta Was this translation helpful? Give feedback.
-
@satoshiotomakan thank you.
The pre-hash of the transaction is valid, because if I manually change the signature in the received JSON to valid signature, the result of the API function will be a hash that matches
Here is my code to generate output
JSON result:
API Call
The expected valid signature should be I know the valid signature because I have a browser extension, that uses the @account-abstraction/contracts package. Maybe I missed some parameters when generation input? But pre-hash is the same and valid. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Hello. Also, I try node lib. Same result. Signature from core-wallet - 0x6591fdd130a3dc87f3b09cd0fe55edae90ccce1e306dce51c648f1742026fdb52f3c6287c0912385852c524bfedff6d53fe76a2b7e8cb672e03de4f66b6237061b Signature from ETH - 0xbc13fcd6f072acd8399356018999e730f0c108ac590f4f76900ec7637417d663138f422f75cd3a277a766d9482b18e6752343bcf8785356c7d1e27b5f1f82db01c Prehash - 0x239e8ae401f75a59a655e782745966a9b8d559f57e02a581cf09516f019a4eac
|
Beta Was this translation helpful? Give feedback.
-
Hello, please help me. I want to receive JSON from user operations EIP-4337.
I received JSON, but JSON does not contain hex values (gas values & nonce)
When I try sent this JSON, I received the error - "Invalid hex value for property nonce:0 in UserOp" or "Invalid hex value for property maxFeePerGas:1507969922 in UserOp".
Please help me, how I can get JSON with hex values. Or what do I need to receive valid EthereumSigningOutput.
And I think the signature is invalid because we do sign not hex values? Or maybe you can help me, with how to receive a valid signature, if I will change all values to hex in JSON.
UserOperation a full user-operation struct. All fields MUST be set as hex values. empty bytes block (e.g. empty initCode) MUST be set to "0x"
My code:
let input = EthereumSigningInput.with { $0.chainID = Data(hexString: "0x000539")! $0.nonce = Data(hexString: "00")! $0.maxFeePerGas = Data(hexString: "0x59e1cb82")! $0.maxInclusionFeePerGas = Data(hexString: "0x59e1cb82")! //maxPriorityFeePerGas $0.txMode = .userOp $0.gasLimit = Data(hexString: "0x5454")! $0.privateKey = wallet.getKeyForCoin(coin: .ethereum).data $0.userOperation = EthereumUserOperation.with { $0.verificationGasLimit = Data(hexString: "0x05f997")! $0.preVerificationGas = Data(hexString: "0x015bd8")! $0.entryPoint = entryPointAddress $0.sender = myWalletTokenAddress $0.initCode = Data(hexString: initCode)! $0.paymasterAndData = Data(hexString: defaultPaymaster)! } }
let output: EthereumSigningOutput = AnySigner.sign(input: input, coin: .ethereum)
let jsonString = String(data: output.encoded, encoding: .utf8)
Example of JSON:
{"callData":"0xb61d27f60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000","callGasLimit":"21588","initCode":"0x40154c8909789bef6e8ed93befd234334c8d11155fbfb9cf000000000000000000000000b40284e302dc2d6e9e7be7784ba0ebe4aef7e5b60000000000000000000000000000000000000000000000000000000000000000","maxFeePerGas":"1507969922","maxPriorityFeePerGas":"1507969922","nonce":"0","paymasterAndData":"0xd0961c1ce3c333040ba3630fc64bf3ea84fef1bf","preVerificationGas":"89048","sender":"0x6d7185f1a41179fc8788a8aed97218d2403375bf","signature":"0x2276b6ce2fbe379d9761177174cdda9e9cfa001d23dd9c31d89c579a9d99e2450135c4f481aa9c44bbe1c52b57461b70ff7ec657931c363131c5d6ce8b086df51b","verificationGasLimit":"391575"}
Beta Was this translation helpful? Give feedback.
All reactions