0

I am getting the following error while signing a simple ether transfer transaction with the Safe Core SDK.

const ethAdapter = new EthersAdapter({
  ethers: ether3,
  signer: ether3.getSigner(0),
})
const safeSdk = await Safe.create({ ethAdapter, safeAddress })
let transaction = {
  to: 'receiver_address',
  data: '0x',
  value: '1000000000000000000',
}
transaction.nonce = await safeService.getNextNonce(safeAddress)
const safeTransaction = await safeSdk.createTransaction(transaction)
await safeSdk.signTransaction(safeTransaction) // this is throwing error
TypeError: Cannot read properties of undefined (reading 'arrayify')
    at EthersAdapter.signMessage (EthersAdapter.js?298f:103:1)
    at generateSignature (index.js?1e12:55:1)
    at async Safe.signTransaction (Safe.js?3512:258:1)

Not able to understand why it is happening because previously I was using web3Adapter and that was not giving any such error.

Edit(25 Jan 2022):

import { ethers } from 'ethers'

const ether3 = new ethers.providers.Web3Provider(window.ethereum) // I am using different provider but it is similar to metamask
const ethAdapter = new EthersAdapter({
  ethers: ether3,
  signer: ether3.getSigner(0),
})
const safeSdk = await Safe.create({ ethAdapter, safeAddress })
let transaction = {
  to: 'receiver_address',
  data: '0x',
  value: '1000000000000000000',
}
transaction.nonce = await safeService.getNextNonce(safeAddress)
const safeTransaction = await safeSdk.createTransaction(transaction)
await safeSdk.signTransaction(safeTransaction) // this is throwing error

signMessage method from the EthersAdapter class:

signMessage(message) {
  const messageArray = __classPrivateFieldGet(this, _EthersAdapter_ethers, "f").utils.arrayify(message);
  return __classPrivateFieldGet(this, _EthersAdapter_signer, "f").signMessage(messageArray);
}

2 Answers 2

1

The error is thrown in the method signMessage from the EthersAdapter class:

signMessage(message: string): Promise<string> {
  const messageArray = this.#ethers.utils.arrayify(message)
  return this.#signer.signMessage(messageArray)
}

where this.#ethers.utils seems to be undefined.

Please, make sure that your object ether3 is valid, it should be imported like this:

import { ethers } from "ethers"
2
  • I checked again all imports are fine. let me update the post to show how I initialized the ether3. Also in my case it is ` signMessage(message) { const messageArray = __classPrivateFieldGet(this, _EthersAdapter_ethers, "f").utils.arrayify(message); return __classPrivateFieldGet(this, _EthersAdapter_signer, "f").signMessage(messageArray); }` Jan 25, 2022 at 7:31
  • 1
    the issue is resolved. The problem was with the initialization of the 'ethAdapter'. It should be like this: ``` const ethAdapter = new EthersAdapter({ ethers, signer: ether3.getSigner(0), }) ``` and not ``` const ethAdapter = new EthersAdapter({ ethers: ether3, signer: ether3.getSigner(0), }) ``` Jan 25, 2022 at 9:08
0

This error is raised because 0x is not valid "arrayify" according to ethers.

https://github.com/ethers-io/ethers.js/blob/3de1b815014b10d223a42e524fe9c25f9087293b/packages/bytes/src.ts/index.ts#L92

Change

let transaction = {
  to: 'receiver_address',
  data: '0x',
  value: '1000000000000000000',
}

to

let transaction = {
  to: 'receiver_address',
  data: '0x00',
  value: '1000000000000000000',
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.