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).
Property | Type | Description | Overrides |
---|---|---|---|
provider | null | Provider | The Provider attached to this Signer (if any). | ContractRunner .provider |
Evaluates th 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.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to call. |
Promise
<string
>
A promise resolving to the result of the call.
ContractRunner.call
Returns a new instance of this Signer connected to provider or detached from any Provider if null.
Parameter | Type | Description |
---|---|---|
provider | null | Provider | The Provider to connect to. |
A new instance of this Signer.
If the Signer cannot be connected to the Provider.
Creates an AccessList for the transaction. This is used to specify which addresses the transaction might touch.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest |
Promise
<AccessList
>
A promise resolving to the access list.
ContractRunner.createAccessList
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.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to estimate gas for. |
Promise
<bigint
>
A promise resolving to the estimated gas.
ContractRunner.estimateGas
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.
Get the address of the Signer.
Promise
<string
>
The address of the Signer.
If the Signer has no address.
Gets the next nonce required for this Signer to send a transaction.
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" ] |
Promise
<number
>
The next nonce.
Prepares a TransactionRequest for calling:
to
and from
addressesfrom
is specified , check that it matches this SignerParameter | Type | Description |
---|---|---|
tx | TransactionRequest | The call to prepare |
Promise
<TransactionLike
>
A promise resolving to the prepared transaction.
Prepares a TransactionRequest for sending to the network by populating any missing properties:
to
and from
addressesfrom
is specified , check that it matches this Signernonce
via signer.getNonce("pending")
gasLimit
via signer.estimateGas(tx)
chainId
via signer.provider.getNetwork()
type
and relevant fee data for that type (gasPrice
)Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to prepare. |
Promise
<TransactionLike
>
A promise resolving to the prepared transaction.
If the transaction is invalid.
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.
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.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to send. |
Promise
<TransactionResponse
>
A promise resolving to the transaction response.
ContractRunner.sendTransaction
If the transaction is invalid.
Signs an 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 ])
).
Parameter | Type | Description |
---|---|---|
message | string | Uint8Array | The message to sign. |
Promise
<string
>
A promise resolving to the signed message.
If the message is invalid.
Signs tx
, returning the fully signed transaction. This does not populate any additional properties within the
transaction.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to sign. |
Promise
<string
>
A promise resolving to the signed transaction.
If the transaction is invalid.
Signs the EIP-712 typed data.
Parameter | Type | Description |
---|---|---|
domain | TypedDataDomain | The domain of the typed data. |
types | Record <string , TypedDataField []> | The types of the typed data. |
value | Record <string , any > | The value of the typed data. |
Promise
<string
>
A promise resolving to the signed typed data.
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).
Property | Type | Description | Overrides |
---|---|---|---|
provider | null | Provider | The Provider attached to this Signer (if any). | ContractRunner .provider |
Evaluates th 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.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to call. |
Promise
<string
>
A promise resolving to the result of the call.
ContractRunner.call
Returns a new instance of this Signer connected to provider or detached from any Provider if null.
Parameter | Type | Description |
---|---|---|
provider | null | Provider | The Provider to connect to. |
A new instance of this Signer.
If the Signer cannot be connected to the Provider.
Creates an AccessList for the transaction. This is used to specify which addresses the transaction might touch.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest |
Promise
<AccessList
>
A promise resolving to the access list.
ContractRunner.createAccessList
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.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to estimate gas for. |
Promise
<bigint
>
A promise resolving to the estimated gas.
ContractRunner.estimateGas
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.
Get the address of the Signer.
Promise
<string
>
The address of the Signer.
If the Signer has no address.
Gets the next nonce required for this Signer to send a transaction.
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" ] |
Promise
<number
>
The next nonce.
Prepares a TransactionRequest for calling:
to
and from
addressesfrom
is specified , check that it matches this SignerParameter | Type | Description |
---|---|---|
tx | TransactionRequest | The call to prepare |
Promise
<TransactionLike
>
A promise resolving to the prepared transaction.
Prepares a TransactionRequest for sending to the network by populating any missing properties:
to
and from
addressesfrom
is specified , check that it matches this Signernonce
via signer.getNonce("pending")
gasLimit
via signer.estimateGas(tx)
chainId
via signer.provider.getNetwork()
type
and relevant fee data for that type (gasPrice
)Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to prepare. |
Promise
<TransactionLike
>
A promise resolving to the prepared transaction.
If the transaction is invalid.
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.
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.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to send. |
Promise
<TransactionResponse
>
A promise resolving to the transaction response.
ContractRunner.sendTransaction
If the transaction is invalid.
Signs an 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 ])
).
Parameter | Type | Description |
---|---|---|
message | string | Uint8Array | The message to sign. |
Promise
<string
>
A promise resolving to the signed message.
If the message is invalid.
Signs tx
, returning the fully signed transaction. This does not populate any additional properties within the
transaction.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to sign. |
Promise
<string
>
A promise resolving to the signed transaction.
If the transaction is invalid.
Signs the EIP-712 typed data.
Parameter | Type | Description |
---|---|---|
domain | TypedDataDomain | The domain of the typed data. |
types | Record <string , TypedDataField []> | The types of the typed data. |
value | Record <string , any > | The value of the typed data. |
Promise
<string
>
A promise resolving to the signed typed data.