Signer
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:14
A Signer represents an account on the Ethereum Blockchain, and is most often backed by a private key represented by a mnemonic or residing on a Hardware Wallet.
The API remains abstract though, so that it can deal with more advanced exotic Signing entities, such as Smart Contract Wallets or Virtual Wallets (where the private key may not be known).
Extends
Section titled “Extends”Properties
Section titled “Properties”provider
Section titled “provider”provider: null | Provider;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:18
The [[Provider]] attached to this Signer (if any).
Overrides
Section titled “Overrides”Methods
Section titled “Methods”authorize()
Section titled “authorize()”authorize(authorization): Promise<Authorization>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:129
Signs an %%authorization%% to be used in [[link-eip-7702]] transactions.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
authorization | AuthorizationRequest |
Returns
Section titled “Returns”call()
Section titled “call()”call(tx): Promise<string>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:86
Evaluates the //tx// by running it against the current Blockchain state. This cannot change state and has no cost in ether, as it is effectively simulating execution.
This can be used to have the Blockchain perform computations based on its state (e.g. running a Contract’s getters) or to simulate the effect of a transaction before actually performing an operation.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
tx | TransactionRequest |
Returns
Section titled “Returns”Promise
<string
>
Overrides
Section titled “Overrides”ContractRunner.call
connect()
Section titled “connect()”connect(provider): Signer;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:23
Returns a new instance of this Signer connected to //provider// or detached from any Provider if null.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
provider | null | Provider |
Returns
Section titled “Returns”Signer
estimateGas()
Section titled “estimateGas()”estimateGas(tx): Promise<bigint>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:76
Estimates the required gas required to execute //tx// on the Blockchain. This
will be the expected amount a transaction will require as its gasLimit
to successfully run all the necessary computations and store the needed state
that the transaction intends.
Keep in mind that this is best efforts, since the state of the Blockchain is in flux, which could affect transaction gas requirements.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
tx | TransactionRequest |
Returns
Section titled “Returns”Promise
<bigint
>
Throws
Section titled “Throws”UNPREDICTABLE_GAS_LIMIT A transaction that is believed by the node to likely
fail will throw an error during gas estimation. This could indicate that it
will actually fail or that the circumstances are simply too complex for the
node to take into account. In these cases, a manually determined gasLimit
will need to be made.
Overrides
Section titled “Overrides”ContractRunner.estimateGas
getAddress()
Section titled “getAddress()”getAddress(): Promise<string>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:27
Get the address of the Signer.
Returns
Section titled “Returns”Promise
<string
>
Overrides
Section titled “Overrides”getNonce()
Section titled “getNonce()”getNonce(blockTag?): Promise<number>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:34
Gets the next nonce required for this Signer to send a transaction.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
blockTag? | BlockTag | The blocktag to base the transaction count on, keep in mind many nodes do not honour this value and silently ignore it [default: "latest" ] |
Returns
Section titled “Returns”Promise
<number
>
populateAuthorization()
Section titled “populateAuthorization()”populateAuthorization(auth): Promise<AuthorizationRequest>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:124
Prepares an [[AuthorizationRequest]] for authorization by populating any missing properties:
- resolves
address
(if an Addressable or ENS name) - populates
nonce
viasigner.getNonce("pending")
- populates
chainId
viasigner.provider.getNetwork()
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
auth | AuthorizationRequest |
Returns
Section titled “Returns”populateCall()
Section titled “populateCall()”populateCall(tx): Promise<TransactionLike<string>>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:42
Prepares a TransactionRequest for calling:
- resolves
to
andfrom
addresses - if
from
is specified , check that it matches this Signer
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The call to prepare |
Returns
Section titled “Returns”Promise
<TransactionLike
<string
>>
populateTransaction()
Section titled “populateTransaction()”populateTransaction(tx): Promise<TransactionLike<string>>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:60
Prepares a TransactionRequest for sending to the network by populating any missing properties:
- resolves
to
andfrom
addresses - if
from
is specified , check that it matches this Signer - populates
nonce
viasigner.getNonce("pending")
- populates
gasLimit
viasigner.estimateGas(tx)
- populates
chainId
viasigner.provider.getNetwork()
- populates
type
and relevant fee data for that type (gasPrice
for legacy transactions,maxFeePerGas
for EIP-1559, etc)
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The call to prepare |
Returns
Section titled “Returns”Promise
<TransactionLike
<string
>>
Some Signer implementations may skip populating properties that are populated downstream; for example JsonRpcSigner defers to the node to populate the nonce and fee data.
resolveName()
Section titled “resolveName()”resolveName(name): Promise<null | string>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:90
Resolves an ENS Name to an address.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
name | string |
Returns
Section titled “Returns”Promise
<null
| string
>
Overrides
Section titled “Overrides”sendTransaction()
Section titled “sendTransaction()”sendTransaction(tx): Promise<TransactionResponse>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:101
Sends %%tx%% to the Network. The signer.populateTransaction(tx)
is called first to ensure all necessary properties for the
transaction to be valid have been popualted first.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
tx | TransactionRequest |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”ContractRunner.sendTransaction
signMessage()
Section titled “signMessage()”signMessage(message): Promise<string>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:112
Signs an [[link-eip-191]] prefixed personal message.
If the %%message%% is a string, it is signed as UTF-8 encoded bytes. It is not
interpretted as a [[BytesLike]]; so the string "0x1234"
is signed as six
characters, not two bytes.
To sign that example as two bytes, the Uint8Array should be used
(i.e. new Uint8Array([ 0x12, 0x34 ])
).
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
message | | string | Uint8Array <ArrayBufferLike > |
Returns
Section titled “Returns”Promise
<string
>
signTransaction()
Section titled “signTransaction()”signTransaction(tx): Promise<string>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:95
Signs %%tx%%, returning the fully signed transaction. This does not populate any additional properties within the transaction.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
tx | TransactionRequest |
Returns
Section titled “Returns”Promise
<string
>
signTypedData()
Section titled “signTypedData()”signTypedData( domain, types,value): Promise<string>;
Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/signer.d.ts:116
Signs the [[link-eip-712]] typed data.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
domain | TypedDataDomain |
types | Record <string , TypedDataField []> |
value | Record <string , any > |
Returns
Section titled “Returns”Promise
<string
>