@@ -2749,32 +2749,34 @@ pub fn encode_usdc_paymaster_data(
2749
2749
}
2750
2750
2751
2751
/// Encode paymaster data for Circle's USDC paymaster
2752
- /// Format: abi.encode(uint256 verificationGasLimit, uint256 callGasLimit)
2753
- /// Note: The paymaster address is NOT included here - it goes in the separate paymaster field
2752
+ /// Format: abi.encode(address paymaster, uint256 verificationGasLimit, uint256 callGasLimit)
2753
+ /// Returns the complete ABI encoding that the paymaster expects to receive
2754
2754
pub fn encode_circle_paymaster_data (
2755
2755
paymaster : EthAddress ,
2756
2756
verification_gas_limit : u128 ,
2757
2757
call_gas_limit : u128 ,
2758
2758
) -> Vec < u8 > {
2759
2759
let mut data = Vec :: new ( ) ;
2760
2760
2761
- // First, add the paymaster address (20 bytes) - this will be extracted by the bundler
2762
- data. extend_from_slice ( paymaster. as_slice ( ) ) ;
2761
+ // ABI encoding includes the paymaster address as the first parameter
2762
+ // This matches the developer's example:
2763
+ // encode(["address", "uint256", "uint256"], ['0x0578cFB241215b77442a541325d6A4E6dFE700Ec', 500000, 300000])
2763
2764
2764
- // Then add the ABI-encoded gas limits (what the paymaster actually expects)
2765
+ // First parameter: paymaster address as uint256 (padded to 32 bytes)
2766
+ let mut padded_address = vec ! [ 0u8 ; 12 ] ; // 12 zero bytes for padding
2767
+ padded_address. extend_from_slice ( paymaster. as_slice ( ) ) ; // 20 bytes of address
2768
+ data. extend_from_slice ( & padded_address) ;
2765
2769
2766
- // Verification gas limit as uint256 (32 bytes)
2770
+ // Second parameter: verification gas limit as uint256 (32 bytes)
2767
2771
let verification_gas_u256 = U256 :: from ( verification_gas_limit) ;
2768
2772
data. extend_from_slice ( & verification_gas_u256. to_be_bytes :: < 32 > ( ) ) ;
2769
2773
2770
- // Call gas limit as uint256 (32 bytes)
2774
+ // Third parameter: call gas limit as uint256 (32 bytes)
2771
2775
let call_gas_u256 = U256 :: from ( call_gas_limit) ;
2772
2776
data. extend_from_slice ( & call_gas_u256. to_be_bytes :: < 32 > ( ) ) ;
2773
2777
2774
- // Total: 84 bytes (20 + 32 + 32)
2775
- // The bundler will split this into:
2776
- // - paymaster: first 20 bytes
2777
- // - paymasterData: remaining 64 bytes (the ABI-encoded gas limits)
2778
+ // Total: 96 bytes (32 + 32 + 32)
2779
+ // This is the complete ABI encoding the paymaster expects
2778
2780
data
2779
2781
}
2780
2782
0 commit comments