Signature
A Signature
TODO
Accessors
compactSerialized
get compactSerialized(): string
The EIP-2098 compact representation.
Returns
string
Source
legacyChainId
get legacyChainId(): null | bigint
The chain ID for EIP-155 legacy transactions. For non-legacy transactions, this value is null
.
Returns
null
| bigint
Source
networkV
get networkV(): null | bigint
The EIP-155 v
for legacy transactions. For non-legacy transactions, this value is null
.
Returns
null
| bigint
Source
r
get r(): string
The r
value for a signautre.
This represents the x
coordinate of a “reference” or challenge point, from which the y
can be computed.
Returns
string
Source
s
get s(): string
The s
value for a signature.
Returns
string
Source
serialized
get serialized(): string
The serialized representation.
Returns
string
Source
v
get v(): 27 | 28
The v
value for a signature.
Since a given x
value for r
has two possible values for its correspondin y
, the v
indicates which of the
two y
values to use.
It is normalized to the values 27
or 28
for legacy purposes.
Returns
27
| 28
Source
yParity
get yParity(): 0 | 1
The yParity
for the signature.
See v
for more details on how this value is used.
Returns
0
| 1
Source
yParityAndS
get yParityAndS(): string
The EIP-2098 compact representation of the yParity
and s
compacted
into a single bytes32
.
Returns
string
Source
Methods
clone()
clone(): Signature
Returns a new identical Signature.
Returns
Source
toJSON()
toJSON(): any
Returns a representation that is compatible with JSON.stringify
.
Returns
any
Source
from()
static from(sig?): Signature
Creates a new Signature.
If no sig
is provided, a new Signature is created with default values.
If sig
is a string, it is parsed.
Parameters
Parameter | Type | Description |
---|---|---|
sig ? | SignatureLike | The signature to create. |
Returns
The new signature.
Source
getChainId()
static getChainId(v): bigint
Compute the chain ID from the v
in a legacy EIP-155 transactions.
Parameters
Parameter | Type | Description |
---|---|---|
v | BigNumberish | The v value from the signature. |
Returns
bigint
The chain ID.
Example
Signature.getChainId(45);
Signature.getChainId(46);
Source
getChainIdV()
static getChainIdV(chainId, v): bigint
Compute the v
for a chain ID for a legacy EIP-155 transactions.
Legacy transactions which use EIP-155 hijack the v
property to
include the chain ID.
Parameters
Parameter | Type | Description |
---|---|---|
chainId | BigNumberish | The chain ID. |
v | 27 | 28 | The v value. |
Returns
bigint
The v
value.
Example
Signature.getChainIdV(5, 27);
Signature.getChainIdV(5, 28);
Source
getNormalizedV()
static getNormalizedV(v): 27 | 28
Compute the normalized legacy transaction v
from a yParirty
, a legacy transaction v
or a legacy
EIP-155 transaction.
Parameters
Parameter | Type | Description |
---|---|---|
v | BigNumberish | The v value. |
Returns
27
| 28
The normalized v
value.
Example
// The values 0 and 1 imply v is actually yParity
Signature.getNormalizedV(0);
// Legacy non-EIP-1559 transaction (i.e. 27 or 28)
Signature.getNormalizedV(27);
// Legacy EIP-155 transaction (i.e. >= 35)
Signature.getNormalizedV(46);
// Invalid values throw
Signature.getNormalizedV(5);
Throws
Thrown if the v
is invalid.
Source
Was this page helpful?