Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

EIP-712 Encoding Error: factoryDeps Elements Not Processed as Complete bytes32 Values #78

@LeXurey

Description

@LeXurey

📝 Description

When encoding transaction data according to the EIP-712 standard in the zksync2-go SDK, the factoryDeps field causes an error. The EIP-712 schema defines factoryDeps as a bytes32[], meaning each element must be exactly 32 bytes in length. However, the SDK is passing factoryDeps as a slice of hexutil.Bytes (i.e., a [][]byte), and during encoding the array elements are processed byte-by-byte rather than as whole 32-byte values. This results in an error such as:

provided data "1" doesn't match type "bytes32"

🔄 Reproduction Steps

  1. Prepare the Contract Binary:
    storage.zbin is the binary being used in my test case.
  2. Read the Contract Binary:
    bytecode, err := os.ReadFile(contractPath) if err != nil { return common.Address{}, fmt.Errorf("failed to pack constructor arguments: %w", err) }
  3. Create a Deployment Transaction:
    createTransaction := zksyncAccount.CreateTransaction{ Bytecode: bytecode, }
  4. Deploy the Contract:
    hash, err := z.wallet.DeployWithCreate(nil, createTransaction) if err != nil { fmt.Println("Hash:", hash) return common.Address{}, fmt.Errorf("failed to deploy with create: %w", err) }
    5.Observe the Error:
    The DeployWithCreate function returns an error. You might see a message similar to:
    provided data "1" doesn't match type "bytes32"

🤔 Expected Behavior

The SDK should treat each element of the factoryDeps array as a complete 32-byte value. The EIP-712 encoder should process each element as a whole rather than iterating over its individual bytes, thus avoiding any type mismatch errors.

😯 Current Behavior

The SDK should treat each element of the factoryDeps array as a complete 32-byte value. The EIP-712 encoder should process each element as a whole rather than iterating over its individual bytes, thus avoiding any type mismatch errors.

🖥️ Environment

  • github.com/zksync-sdk/zksync2-go Version: v1.0.0
  • contract binary file: storage.zbin

📋 Additional Context

The error is being triggered from within the encodeArrayValue function, which is called by EncodeData when processing array types. This function is defined in the file:
/Users/$user/go/pkg/mod/github.com/ethereum/go-ethereum@v1.15.0/signer/core/apitypes/types.go

📎 Log Output

    zksync_deploy_test.go:33: failed to deploy smart contract: failed to deploy with create: failed to get hash of typed data: failed to get hash of typed message: provided data '1' doesn't match type 'bytes32'
--- FAIL: TestDeploySmartContractIntegration (2507.04s)
FAIL

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions