📝 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
- Prepare the Contract Binary:
storage.zbin is the binary being used in my test case.
- Read the Contract Binary:
bytecode, err := os.ReadFile(contractPath) if err != nil { return common.Address{}, fmt.Errorf("failed to pack constructor arguments: %w", err) }
- Create a Deployment Transaction:
createTransaction := zksyncAccount.CreateTransaction{ Bytecode: bytecode, }
- 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
📝 Description
When encoding transaction data according to the EIP-712 standard in the zksync2-go SDK, the
factoryDepsfield causes an error. The EIP-712 schema definesfactoryDepsas abytes32[], meaning each element must be exactly 32 bytes in length. However, the SDK is passingfactoryDepsas a slice ofhexutil.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
storage.zbin is the binary being used in my test case.
bytecode, err := os.ReadFile(contractPath) if err != nil { return common.Address{}, fmt.Errorf("failed to pack constructor arguments: %w", err) }createTransaction := zksyncAccount.CreateTransaction{ Bytecode: bytecode, }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
📋 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