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

Transaction type EIP712_TX_TYPE not supported #202

Open
MickWang opened this issue Sep 23, 2024 · 1 comment
Open

Transaction type EIP712_TX_TYPE not supported #202

MickWang opened this issue Sep 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@MickWang
Copy link

Ethers Version

6.13.2

Search Terms

EIP712_TX_TYPE, eip712

Describe the Problem

User zksync-ethers(v6.12.1) signer to send EIP712 transaction, zksync-ethers depends on ethers.js v6. The transaction can be sent and confirmed on chain. There is an error happens in ethers's abstract-provider (https://github.com/ethers-io/ethers.js/blob/5aba4963e3e8ddfc912747076f5b7fe7a743cfe2/src.ts/providers/abstract-provider.ts#L1088), where it use Trnsaction.from(signedTx) and got error as :
Error: unsupported transaction type (operation="from", code=UNSUPPORTED_OPERATION, version=6.13.2). So the transaction type EIP712 is not supported in transaction.js.

Code Snippet

const transaction = {...tx}
transaction.customData = tx.customData;
                const zksyncSigner = ZksyncSigner.from(
                  // @ts-ignore
                  signer,
                  tx.chainId,
                  new ZksyncProvider(getRpc(tx.chainId))
                );
                const res = await zksyncSigner.sendTransaction({
                  ...transaction,
                  gasLimit: fee.gasLimit,
                  maxPriorityFeePerGas: Number(fee.maxPriorityFeePerGas)
                    ? fee.maxPriorityFeePerGas
                    : 100,
                });
                return res;

Contract ABI

No response

Errors

Error: unsupported transaction type (operation="from", code=UNSUPPORTED_OPERATION, version=6.13.2)
    at makeError (errors.js:137:21)
    at assert (errors.js:156:15)
    at Transaction.from (transaction.js:933:68)
    at BrowserProvider.broadcastTransaction (abstract-provider.js:761:83)
    at async Signer.sendTransaction (signer.js:593:20)
    at async eval (useSendMultichainTx.ts:489:29)
    at async eval (SignButton.tsx:97:26)

Environment

Ethereum (mainnet/ropsten/rinkeby/goerli)

Environment (Other)

No response

@danijelTxFusion
Copy link
Collaborator

danijelTxFusion commented Oct 2, 2024

Hi @MickWang

I managed to run succefully the EIP712 transaction using ethers 6.13.2 and zksync-ethers: 6.12.1. Here is the code:

import {Provider, types, utils, BrowserProvider, Signer} from 'zksync-ethers';
import {ethers} from 'ethers';

const token = '0x6a4Fb925583F7D4dF82de62d98107468aE846FD1';
const receiver = '0x81E9D85b65E9CC8618D85A1110e4b1DF63fA30d9';
const approvalToken = '0x927488F48ffbc32112F1fF721759649A89721F8F'; // Crown token which can be minted for free
const paymaster = '0x13D0D8550769f59aa241a41897D4859c87f7Dd46'; // Paymaster for Crown token

// Browser wallet should be connected to zkSync Era Sepolia network
const browserProvider = new BrowserProvider((window as any).ethereum);
const provider = Provider.getDefaultProvider(types.Network.Sepolia);
const signer = Signer.from(
     await browserProvider.getSigner(),
     Number((await browserProvider.getNetwork()).chainId),
     provider
);

console.log(`Account1 balance before transfer: ${await signer.getBalance()}`);
console.log(`Account2 balance before transfer: ${await provider.getBalance(receiver)}`);

await signer.sendTransaction({
     from: signer.address,
     to: receiver,
     value: ethers.parseEther('0.01'),
     customData: {
          paymasterParams: utils.getPaymasterParams(paymaster, {
             type: 'ApprovalBased',
             token: approvalToken,
             minimalAllowance: 1,
             innerInput: new Uint8Array(),
           }),
      }
 })
        
console.log(`Account1 balance after transfer: ${await signer.getBalance()}`);
console.log(`Account2 balance after transfer: ${await provider.getBalance(receiver)}`);

Output:

Account1 balance before transfer: 75700023965349567071
Account2 balance before transfer: 192408413800010000
Account1 balance after transfer: 75690023965349567071
Account2 balance after transfer: 202408413800010000

Transaction on Sepolia: https://sepolia.explorer.zksync.io/tx/0x3e915f988411b307090176b96cdf178e0ce09fe9c602bd1c8711930e19c402e8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants