A Signature

TODO

Accessors

compactSerialized

get compactSerialized(): string
The EIP-2098 compact representation.

Returns

string

Source

crypto/signature.ts:161

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

crypto/signature.ts:128

networkV

get networkV(): null | bigint
The EIP-155 v for legacy transactions. For non-legacy transactions, this value is null.

Returns

null | bigint

Source

crypto/signature.ts:121

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

crypto/signature.ts:80

s

get s(): string
The s value for a signature.

Returns

string

Source

crypto/signature.ts:91

serialized

get serialized(): string
The serialized representation.

Returns

string

Source

crypto/signature.ts:168

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

crypto/signature.ts:109

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

crypto/signature.ts:141

yParityAndS

get yParityAndS(): string
The EIP-2098 compact representation of the yParity and s compacted into a single bytes32.

Returns

string

Source

crypto/signature.ts:149

Methods

clone()

clone(): Signature
Returns a new identical Signature.

Returns

Signature

Source

crypto/signature.ts:190

toJSON()

toJSON(): any
Returns a representation that is compatible with JSON.stringify.

Returns

any

Source

crypto/signature.ts:201

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

ParameterTypeDescription
sig?SignatureLikeThe signature to create.

Returns

Signature The new signature.

Source

crypto/signature.ts:312

getChainId()

static getChainId(v): bigint
Compute the chain ID from the v in a legacy EIP-155 transactions.

Parameters

ParameterTypeDescription
vBigNumberishThe v value from the signature.

Returns

bigint The chain ID.

Example

Signature.getChainId(45);

Signature.getChainId(46);

Source

crypto/signature.ts:226

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

ParameterTypeDescription
chainIdBigNumberishThe chain ID.
v27 | 28The v value.

Returns

bigint The v value.

Example

Signature.getChainIdV(5, 27);

Signature.getChainIdV(5, 28);

Source

crypto/signature.ts:258

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

ParameterTypeDescription
vBigNumberishThe 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

crypto/signature.ts:286