Skip to content

TypeScript error: ethers.Transaction.from won't accept ethers.TransactionRequest #4659

@lastmjs

Description

@lastmjs

Ethers Version

6.11.1

Search Terms

No response

Describe the Problem

While implementing signTransaction within my own concrete implementation of ethers.AbstractSigner, I am trying to create a transaction using ethers.Transaction.from with an ethers.TransactionRequest as the argument. I would think that this could work, but unfortunately there is a TypeScript error. At runtime everything is working fine thus far.

Code Snippet

// implementing my own ethers.AbstractSigner
async signTransaction(
    txRequest: ethers.TransactionRequest
): Promise<string> {
    let tx = ethers.Transaction.from(txRequest);
    // Here I have custom signing logic doing threshold ECDSA
}

Contract ABI

No response

Errors

Argument of type 'TransactionRequest' is not assignable to parameter of type 'string | TransactionLike<string> | undefined'.
  Type 'TransactionRequest' is not assignable to type 'TransactionLike<string>'.
    Types of property 'to' are incompatible.
      Type 'AddressLike | null | undefined' is not assignable to type 'string | null | undefined'.
        Type 'Promise<string>' is not assignable to type 'string'.ts(2345)

Environment

node.js (v12 or newer)

Environment (Other)

VS Code

Metadata

Metadata

Assignees

Labels

documentationDocumentation related issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions