Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Paymasters #95

Open
mationorato opened this issue Aug 2, 2023 · 4 comments
Open

Add Support for Paymasters #95

mationorato opened this issue Aug 2, 2023 · 4 comments

Comments

@mationorato
Copy link
Collaborator

mationorato commented Aug 2, 2023

Add support for using paymasters with EIP712 trasnsactions.

Useful links:

@ETeissonniere
Copy link

We'd be softly interested in adding this feature depending on how much support can be provided in terms of notes on integration points. Are you able to provide more details on this?

@aliXsed
Copy link

aliXsed commented Nov 4, 2024

Checking with @IAvecilla who has recently contributed to the paymaster example in the lib. Is this feature now complete and tested?

@aliXsed
Copy link

aliXsed commented Nov 6, 2024

Since no response to my previous comments, I would like to tag @ischasny in case he'd be able to update this ticket. We are currently running into an issue in interacting with a paymaster that is setup by ZyFi. We get the paymaster params from the ZyFi's api server and use the following code snippet that is based upon the latest zksync-web3-rs to make our paymaster transaction:

        info!(response = ?response, "ZyFi Response");

        let chain_id = response.tx_data.chain_id;
        let from = parse_ethereum_address(&response.tx_data.from)?;
        let to = parse_ethereum_address(&response.tx_data.to)?;
        let data = hex::decode(response.tx_data.data)?;
        let value = parse_u256(&response.tx_data.value)?;
        let paymaster =
            parse_ethereum_address(&response.tx_data.custom_data.paymaster_params.paymaster)?;
        let paymaster_input = hex::decode(
            response
                .tx_data
                .custom_data
                .paymaster_params
                .paymaster_input,
        )?;
        let gas_per_pubdata = response.tx_data.custom_data.gas_per_pubdata;
        let gas_limit = response.tx_data.gas_limit;
        let max_fee_per_gas = parse_u256(&response.tx_data.max_fee_per_gas)?;

        Ok(Eip712TransactionRequest::new()
            .from(from)
            .to(to)
            .data(data)
            .custom_data(
                Eip712Meta::new()
                    .paymaster_params(PaymasterParams {
                        paymaster,
                        paymaster_input,
                    })
                    .gas_per_pubdata(gas_per_pubdata),
            )
            .chain_id(chain_id)
            .gas_limit(gas_limit)
            .max_fee_per_gas(max_fee_per_gas)
            .value(value))
    }

When this transaction is delivered the response is:

Error: (code: 3, message: failed paymaster validation. error message: Error function_selector = 0x81b5ad68, data = 0x81b5ad68, data: Some(String("0x")))

Since we do not have such an issue when interacting with the same paymaster in our other non-rust apps, our main suspicion is the paymaster support in zksync-web3-rs may have an issue, hence our interest in the fate of this ticket.

@hoshiyari420
Copy link

Hi team, I am working with Zyfi to identify the root cause mentioned here by @aliXsed.

The error may suggest it is the paymaster validation here but it's not. The error here is that the paymaster_input should be a hex string but it's being sent as uint array because of which the validation fails on the paymaster.

pub paymaster_input: Vec<u8>,

Please do look into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants