Mobile work-around

After weeks of research, we've discovered that the classic frontend implementation for paymaster transactions is incompatible with most mobile wallets . We've found a workaround to resolve this, benefiting the entire ZKsync ecosystem.

Paymaster transactions require your RPC endpoint to support the eth_sendRawTransaction method to function properly. Unfortunately, many mobile wallets do not natively support this method or lose support after using third-party services like WalletConnect.

To work around this, you can request the user's signature and then broadcast it directly to a custom RPC endpoint that supports it like here:

  const txReq = await wClient.prepareTransactionRequest({
      account: address,
      to: toAddress,
      value: ETH_AMOUNT,
      chain: zkSync,
      gas: BigInt(pmData.gasLimit),
      gasPerPubdata: BigInt(pmData.txData.customData.gasPerPubdata),
      maxFeePerGas: BigInt(pmData.txData.maxFeePerGas),
      maxPriorityFeePerGas: 0n,
      data: pmData.txData.data,
      paymaster: pmData.txData.customData.paymasterParams.paymaster,
      paymasterInput: pmData.txData.customData.paymasterParams.paymasterInput,
    })

It's a workaround that works perfectly for Dapps wanting to support paymaster functionality on mobile within ZKsync chains.

Last updated