Skip to content

Signers (Signer)

A signer holds accounts and makes them sign: a local key, a wallet, or the wallet an app is connected to. Each one is a Layer that provides the Signer service, which Tx sends through. A program that only reads needs no signer, and one that sends does not compile without one.

import { Signer } from "@ethect/core";
Export Kind Description
Signer.privateKey(key, options?) layer A local key. Always a Redacted: a plain string does not compile.
Signer.fromSign(account, options?) layer Anything that signs a digest: a KMS, an HSM.
Signer.make(account, options?) layer An account that signs transactions, messages and typed data itself.
Signer.all(...signers) layer Several signers as one: from picks the account.
Signer.wallet(provider, options?) layer An EIP-1193 wallet.
Signer.connected(options?) layer The wallet the app is connected to, whichever it is at the time.
Signer.accounts effect The accounts the signer holds.
Signer.address effect The first of them: the sender when no from is given.
Signer.capabilities(options?) function What the signer can do for an account on a chain.
Signer.signMessage(message, options?) function Signs a message, and sends nothing.
Signer.signTypedData(data, options?) function Signs EIP-712 typed data.
Signer.signTransaction(call, options?) function Signs a call as a transaction, and sends nothing.
Signer.Nonces strategies How a local signer hands out nonces: serial, the default, or pipelined.
Signer.Signer service What every signer provides.
Signer.Error error The signer cannot do what was asked. Its _tag is "SignerError", and reason says why.
Signer.Rejected error The user refused what the wallet asked: to connect, to sign, to switch chain.
Signer.Estimate module Signer.Estimate.Reverted: what a signer fails with when a call would revert, before anything is signed.
Signer.Capabilities type atomic, unattended, and all that a wallet reports.
Signer.TypedData type EIP-712 typed data: domain, types, primaryType, message.
Signer.Signed type A transaction that is signed and not sent: raw, hash, nonce, from, chainId.
Signer.Account type What Signer.make takes: an address and the three functions that sign.
Signer.Unsigned type A transaction with every field decided, as an Account signs it.
Signer.LocalOptions type The options of a signer that signs here: nonces.

A signer of your own is a layer that provides Signer.Signer. Calls arrive encoded: a signer never sees an ABI. It uses the Transport of whoever calls it, and keeps none of its own.

Member Does
accounts The accounts it holds.
capabilities(account, chainId) What it can do for an account on a chain.
submit(request) Signs the calls as one and hands them to the network. Gives a Tx.Pending.
status(handle) Where a Tx.Handle it gave stands: a Tx.Handle.Status, with hashes and no receipts.
signMessage(account, message) Signs the bytes of a message.
signTypedData(account, data) Signs typed data.
signTransaction(account, call, fields) Signs a transaction, and sends nothing.
Signer.Error reason Means
"Unauthorized" the signer does not hold the account, or holds none
"ChainMismatch" the wallet is on another chain than the transaction is for
"UnknownChain" the wallet does not know the chain
"Disconnected" no wallet is connected, or it cannot be reached
"InvalidKey" what was given as a key is not one
"UnknownBatch" the wallet does not know the batch it is asked about: it is not the wallet that took it, or it has forgotten it. The batch may still be mined
"Unknown" anything else. cause holds what the wallet answered: its refusal, an RpcError, or a CodecError for an answer that cannot be read, with the answer as its value

A local key signs in your program and sends through your node. A wallet is asked for everything.

  1. a local key: Signer.privateKey, Signer.fromSign

    1. your programthe accounts and every signature. No request
    2. your nodeeth_sendRawTransactionto send, after the fees, the gas and the nonce
  2. a wallet: Signer.wallet, Signer.connected

    1. the walleteth_accountsthe accounts. Signer.connected has them from the connection, with no request
    2. the walleteth_chainIdbefore every signature that is for a chain
    3. the walleteth_sendTransactionone call. Several calls: wallet_sendCalls
    4. the walletpersonal_signa message. Typed data: eth_signTypedData_v4

See Signer.privateKey, Signer.wallet and Signer.connected.