Issue encountered with the signature provided for a Safe API POST request

Watch this demonstration video of the issue at hand:

I have created a signer using my Metamask Private Key and generated a signature from it as shown below:

const signer = new ethers.Wallet(PRIVATE_KEY as string, provider)
const safeInstance = new ethers.Contract(safeAddress, safeAbi, signer)
const safeTrxHash = await safeInstance.getTransactionHash(
      trxInput.to,
      trxInput.value,
      trxInput.data,
      trxInput.operation,
      trxInput.safeTxGas,
      trxInput.baseGas,
      trxInput.gasPrice,
      trxInput.gasToken,
      trxInput.refundReceiver,
      trxInput.nonce,
    )

const signature = (await signer.signMessage(safeTrxHash))
      .replace(/1b$/, '1f')
      .replace(/1c$/, '20')

When I pass this signature to the API endpoint , I encounter the following error message:

data: `{"nonFieldErrors":["Signer=0x2C7DC84b0aad92978B8D2F2fc72aBd6013cF6EB4 is not an owner or delegate. Current owners=['0xE28312CF65663803d1317c1ccf261E1edEC1FF6d']. Delegates=set()"]}

The address identified as the signer is unfamiliar to me, however, the address listed as one of the current owners is the correct one that I provided. I suspect that the error may be related to how the signature was generated.

Any assistance in resolving this issue would be greatly appreciated.

View the Loom Video for more information:

Answer №1

For seamless interaction with Safe services, we recommend utilizing our API kit available at

Answer №2

When it comes to ethers version 5, there is a common issue that often gets overlooked.

The ethers.signMessage() function abstracts how it interprets the message argument. If you provide an array like ['0xab', '0xbc'], ethers will treat it as Bytes. However, if you pass a hash value represented as a string like 0xabbc, ethers will interpret it as a string.

To sign a hash using ethers.signMessage, you must explicitly convert the hash into a bytes array using arrayify.

To resolve this issue, generate the signature using:

const signature = (await signer.signMessage(ethers.utils.arrayify(safeTrxHash)))
      .replace(/1b$/, '1f')
      .replace(/1c$/, '20')

Sources:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering an Angular 13 ChunkLoadError during application deployment, despite the presence of the respective chunk

We encountered an issue with our application's upgrade from Angular 11 to 13. While running 'ng serve' on the local machine works fine, deploying it to our Azure app service causes the lazy loaded modules to fail loading. The specific error ...

Ways to slow down page transition on NextJs

I'm currently working on securing my private pages using a HOC withAuth. While the protection is functioning correctly, I am looking to avoid users seeing a loading screen for a split second while the access token is being retrieved from local storage ...

Navigating the deployment of a NextJs SSR application on Amplify with Lambda@Edge (Encountering a 503 Error

My current process involves building and deploying a Next.js app on Amplify, where it automatically recognizes the .yml file in the root directory. It then sets up resources such as Default Edge Lambda, Cloudfront Distribution, and S3 bucket for hosting an ...

Sharing a Promise between Two Service Calls within Angular

Currently, I am making a service call to the backend to save an object and expecting a number to be returned via a promise. Here is how the call looks: saveTcTemplate(item: ITermsConditionsTemplate): ng.IPromise<number> { item.modifiedDa ...

Instructions for incorporating a button onto a tableCell within a material UI table

I am currently working on a Next.js project where I am using Material UI to create tables and fetching data from MongoDB. However, I am facing an issue in adding edit and delete buttons to the action column in the table. Below is how the current table loo ...

What is the correct way to implement fetch in a React/Redux/TS application?

Currently, I am developing an application using React, Redux, and TypeScript. I have encountered an issue with Promises and TypeScript. Can you assist me in type-defining functions/Promises? An API call returns a list of post IDs like [1, 2, ..., 1000]. I ...

Relocating the node_modules folder results in syntax errors arising

I encountered a perplexing syntax error issue. I noticed that having a node_modules directory in the same location I run npm run tsc resolves the issue with no syntax errors. However, after relocating the node_modules directory to my home directory, ~ , a ...

Angular TextInput Components don't seem to function properly when dealing with arrays

I am trying to create a collection of text input components with values stored in an array. However, when using the following code, the values seem to be placed incorrectly in the array and I cannot identify the bug. <table> <tr *ngFor="let opt ...

How can I define Record values in Typescript based on their specific keys?

I am working on creating a custom data structure that allows me to store values with string keys within the union string | number | boolean: type FilterKey = string; type FilterValue = string | number | boolean; type Filters<K extends FilterKey, T exten ...

Preventing a user from accessing the login page if they are already logged in using Reactjs

I need assistance with implementing a "Login Logout" module in Reactjs using the nextjs framework. My goal is to redirect users to the "dashboard" page if they are logged in (email set in cookie). However, I am encountering an error with the following co ...

Http service not found

I am facing a problem with injecting HTTP into my Angular 2 application. Everything was working smoothly a few days ago, but now I am encountering this error: ORIGINAL EXCEPTION: No provider for Http! Here is the code snippet from main.ts: import { pl ...

What is the recommended data type for Material UI Icons when being passed as props?

What specific type should I use when passing Material UI Icons as props to a component? import {OverridableComponent} from "@mui/material/OverridableComponent"; import {SvgIconTypeMap} from "@mui/material"; interface IconButtonProps { ...

What methods does Angular use to determine the parameter types of a constructor?

I've been experimenting with replicating Angular's approach to interpreting the constructor in an injectable service. function Injectable() { return function<T extends { new (...args: any[]): {} }>(con: T) { return class extends con ...

Tips for refreshing a component after fetching a new page using the useQuery function

Attempting to retrieve and display data from my custom API using axios and react-query's useQuery. The API incorporates pagination, and I have implemented a table with an option to select the page that displays the current data. Everything functions c ...

Incorporate a fresh element into an object after its initial creation

Hello, I am looking to create an object in JavaScript that includes an array-object field called "Cities." Within each city entry, there should be information such as the city's name, ID, key, and a District array object containing town data for that ...

Implementing various custom validation techniques in Angular 2

I am encountering an issue with adding multiple custom validations to a form. Currently, I am only able to add a single custom validation to my form. How can I include multiple validations? For example: this.user = this.fb.group({ name: ['', ...

What is the best way to have text wrap around an icon in my React application?

I am facing an issue while trying to display the note description over the trash icon in a React app. I have tried various methods but can't seem to achieve the desired effect. Can anyone guide me on how to get this layout? Here is what I intend to a ...

Unleashing the power of Sass and CSS in your Next Js project

Trying to incorporate sass and css modules into my next.config.js has been challenging due to an error I keep encountering: Failed to compile. ./node_modules/@riskalyze/react-ui/node_modules/@riskalyze/calendar/assets/index.css Unknown word (1:1) > 1 ...

The not-null constraint is violated in the "id" column because of a null value when using Sequelize Typescript

My Database Setup Journey Recently, I embarked on a database adventure where I decided to use Sequelize-Typescript to assist me with all the heavy lifting in terms of database operations. The first step was creating a table called uma_tbl_users, and here ...

What makes TS unsafe when using unary arithmetic operations, while remaining safe in binary operations?

When it comes to arithmetic, there is a certain truth that holds: if 'a' is any positive real number, then: -a = a*(-1) The Typescript compiler appears to have trouble reproducing arithmetic rules in a type-safe manner. For example: (I) Workin ...