///
import type { AbstractIteratorOptions as AbstractIteratorOptions_2 } from 'abstract-level';
import type { AbstractLevel } from 'abstract-level';
import crypto from 'crypto';
import Emittery from 'emittery';
import { EventEmitter } from 'events';
import * as LRUCache from 'lru-cache';
import { Readable } from 'readable-stream';
import seedrandom from 'seedrandom';
import { URL } from 'url';
/**
* @experimental
*/
export declare const __experimental_info: () => _ExperimentalInfo;
declare class AbortError extends Error {
constructor();
}
declare type AbstractBatch = PutBatch | DelBatch;
declare interface AbstractChainedBatch extends AbstractOptions {
put: (key: K, value: V) => this;
del: (key: K) => this;
clear: () => this;
write(cb: ErrorCallback): any;
write(options: any, cb: ErrorCallback): any;
}
declare const AbstractChainedBatch: AbstractChainedBatchConstructor;
declare interface AbstractChainedBatchConstructor {
// tslint:disable-next-line no-unnecessary-generics
new (db: any): AbstractChainedBatch;
// tslint:disable-next-line no-unnecessary-generics
(db: any): AbstractChainedBatch;
}
declare interface AbstractClearOptions extends AbstractOptions {
gt?: K | undefined;
gte?: K | undefined;
lt?: K | undefined;
lte?: K | undefined;
reverse?: boolean | undefined;
limit?: number | undefined;
}
declare interface AbstractGetOptions extends AbstractOptions {
asBuffer?: boolean | undefined;
}
declare interface AbstractIterator extends AbstractOptions {
db: AbstractLevelDOWN;
next(cb: ErrorKeyValueCallback): this;
end(cb: ErrorCallback): void;
}
declare const AbstractIterator: AbstractIteratorConstructor;
declare interface AbstractIteratorConstructor {
// tslint:disable-next-line no-unnecessary-generics
new (db: any): AbstractIterator;
// tslint:disable-next-line no-unnecessary-generics
(db: any): AbstractIterator;
}
declare interface AbstractIteratorOptions extends AbstractOptions {
gt?: K | undefined;
gte?: K | undefined;
lt?: K | undefined;
lte?: K | undefined;
reverse?: boolean | undefined;
limit?: number | undefined;
keys?: boolean | undefined;
values?: boolean | undefined;
keyAsBuffer?: boolean | undefined;
valueAsBuffer?: boolean | undefined;
}
declare interface AbstractLevelDOWN extends AbstractOptions {
open(cb: ErrorCallback): void;
open(options: AbstractOpenOptions, cb: ErrorCallback): void;
close(cb: ErrorCallback): void;
get(key: K, cb: ErrorValueCallback): void;
get(key: K, options: AbstractGetOptions, cb: ErrorValueCallback): void;
put(key: K, value: V, cb: ErrorCallback): void;
put(key: K, value: V, options: AbstractOptions, cb: ErrorCallback): void;
del(key: K, cb: ErrorCallback): void;
del(key: K, options: AbstractOptions, cb: ErrorCallback): void;
getMany(key: K[], cb: ErrorValueCallback): void;
getMany(key: K[], options: AbstractGetOptions, cb: ErrorValueCallback): void;
batch(): AbstractChainedBatch;
batch(array: ReadonlyArray>, cb: ErrorCallback): AbstractChainedBatch;
batch(
array: ReadonlyArray>,
options: AbstractOptions,
cb: ErrorCallback,
): AbstractChainedBatch;
iterator(options?: AbstractIteratorOptions): AbstractIterator;
readonly status: "new" | "opening" | "open" | "closing" | "closed";
isOperational(): boolean;
}
declare const AbstractLevelDOWN: AbstractLevelDOWNConstructor;
declare interface AbstractLevelDOWNConstructor {
// tslint:disable-next-line no-unnecessary-generics
new (location: string): AbstractLevelDOWN;
// tslint:disable-next-line no-unnecessary-generics
(location: string): AbstractLevelDOWN;
}
declare interface AbstractOpenOptions extends AbstractOptions {
createIfMissing?: boolean | undefined;
errorIfExists?: boolean | undefined;
}
declare interface AbstractOptions {
readonly [k: string]: any;
}
declare type AccessList = AccessListItem[];
declare type AccessList_2 = AccessListItem_2[];
declare type AccessListBuffer = AccessListBufferItem[];
declare type AccessListBufferItem = [Buffer, Buffer[]];
/**
* Typed transaction with optional access lists
*
* - TransactionType: 1
* - EIP: [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930)
*/
declare class AccessListEIP2930Transaction extends BaseTransaction_2 {
readonly chainId: bigint;
readonly accessList: AccessListBuffer;
readonly AccessListJSON: AccessList;
readonly gasPrice: bigint;
readonly common: Common;
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
protected DEFAULT_HARDFORK: string;
/**
* Instantiate a transaction from a data dictionary.
*
* Format: { chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
* v, r, s }
*
* Notes:
* - `chainId` will be set automatically if not provided
* - All parameters are optional and have some basic default values
*/
static fromTxData(txData: AccessListEIP2930TxData, opts?: TxOptions): AccessListEIP2930Transaction;
/**
* Instantiate a transaction from the serialized tx.
*
* Format: `0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
* signatureYParity (v), signatureR (r), signatureS (s)])`
*/
static fromSerializedTx(serialized: Buffer, opts?: TxOptions): AccessListEIP2930Transaction;
/**
* Create a transaction from a values array.
*
* Format: `[chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
* signatureYParity (v), signatureR (r), signatureS (s)]`
*/
static fromValuesArray(values: AccessListEIP2930ValuesArray, opts?: TxOptions): AccessListEIP2930Transaction;
/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData: AccessListEIP2930TxData, opts?: TxOptions);
/**
* The amount of gas paid for the data in this tx
*/
getDataFee(): bigint;
/**
* The up front amount that an account must have for this transaction to be valid
*/
getUpfrontCost(): bigint;
/**
* Returns a Buffer Array of the raw Buffers of the EIP-2930 transaction, in order.
*
* Format: `[chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
* signatureYParity (v), signatureR (r), signatureS (s)]`
*
* Use {@link AccessListEIP2930Transaction.serialize} to add a transaction to a block
* with {@link Block.fromValuesArray}.
*
* For an unsigned tx this method uses the empty Buffer values for the
* signature parameters `v`, `r` and `s` for encoding. For an EIP-155 compliant
* representation for external signing use {@link AccessListEIP2930Transaction.getMessageToSign}.
*/
raw(): AccessListEIP2930ValuesArray;
/**
* Returns the serialized encoding of the EIP-2930 transaction.
*
* Format: `0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
* signatureYParity (v), signatureR (r), signatureS (s)])`
*
* Note that in contrast to the legacy tx serialization format this is not
* valid RLP any more due to the raw tx type preceding and concatenated to
* the RLP encoding of the values.
*/
serialize(): Buffer;
/**
* Returns the serialized unsigned tx (hashed or raw), which can be used
* to sign the transaction (e.g. for sending to a hardware wallet).
*
* Note: in contrast to the legacy tx the raw message format is already
* serialized and doesn't need to be RLP encoded any more.
*
* ```javascript
* const serializedMessage = tx.getMessageToSign(false) // use this for the HW wallet input
* ```
*
* @param hashMessage - Return hashed message if set to true (default: true)
*/
getMessageToSign(hashMessage?: boolean): Buffer;
/**
* Computes a sha3-256 hash of the serialized tx.
*
* This method can only be used for signed txs (it throws otherwise).
* Use {@link AccessListEIP2930Transaction.getMessageToSign} to get a tx hash for the purpose of signing.
*/
hash(): Buffer;
/**
* Computes a sha3-256 hash which can be used to verify the signature
*/
getMessageToVerifySignature(): Buffer;
/**
* Returns the public key of the sender
*/
getSenderPublicKey(): Buffer;
_processSignature(v: bigint, r: Buffer, s: Buffer): AccessListEIP2930Transaction;
/**
* Returns an object with the JSON representation of the transaction
*/
toJSON(): JsonTx;
/**
* Return a compact error string representation of the object
*/
errorStr(): string;
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string): string;
}
/**
* {@link AccessListEIP2930Transaction} data.
*/
declare interface AccessListEIP2930TxData extends TxData {
/**
* The transaction's chain ID
*/
chainId?: BigIntLike;
/**
* The access list which contains the addresses/storage slots which the transaction wishes to access
*/
accessList?: AccessListBuffer | AccessList;
}
/**
* Buffer values array for an {@link AccessListEIP2930Transaction}
*/
declare type AccessListEIP2930ValuesArray = [
Buffer,
Buffer,
Buffer,
Buffer,
Buffer,
Buffer,
Buffer,
AccessListBuffer,
Buffer?,
Buffer?,
Buffer?
];
declare type AccessListItem = {
address: PrefixedHexString;
storageKeys: PrefixedHexString[];
};
declare type AccessListItem_2 = {
address: PrefixedHexString;
storageKeys: PrefixedHexString[];
};
declare class Account {
address: Address;
balance: Quantity;
privateKey: Data;
nonce: Quantity;
storageRoot: Buffer;
codeHash: Buffer;
constructor(address: Address);
static fromBuffer(buffer: Buffer): any;
serialize(): Buffer;
}
declare class Account_2 {
nonce: bigint;
balance: bigint;
storageRoot: Buffer;
codeHash: Buffer;
static fromAccountData(accountData: AccountData): Account_2;
static fromRlpSerializedAccount(serialized: Buffer): Account_2;
static fromValuesArray(values: Buffer[]): Account_2;
/**
* This constructor assigns and validates the values.
* Use the static factory methods to assist in creating an Account from varying data types.
*/
constructor(nonce?: bigint, balance?: bigint, storageRoot?: Buffer, codeHash?: Buffer);
private _validate;
/**
* Returns a Buffer Array of the raw Buffers for the account, in order.
*/
raw(): Buffer[];
/**
* Returns the RLP serialization of the account as a `Buffer`.
*/
serialize(): Buffer;
/**
* Returns a `Boolean` determining if the account is a contract.
*/
isContract(): boolean;
/**
* Returns a `Boolean` determining if the account is empty complying to the definition of
* account emptiness in [EIP-161](https://eips.ethereum.org/EIPS/eip-161):
* "An account is considered empty when it has no code and zero nonce and zero balance."
*/
isEmpty(): boolean;
}
declare class Account_3 extends SerializableObject implements DeserializedObject {
#private;
get config(): Definitions;
static random(defaultFIL: number, rng?: RandomNumberGenerator, protocol?: AddressProtocol, network?: AddressNetwork): Account_3;
constructor(options?: Partial> | Partial>);
addBalance(val: string | number | bigint): void;
subtractBalance(val: string | number | bigint): void;
readonly address: Address_3;
nonce: number;
get balance(): Balance;
}
declare type AccountConfig = {
properties: {
address: {
type: Address_3;
serializedType: SerializedAddress;
serializedName: "Address";
};
balance: {
type: Balance;
serializedType: SerializedBalance;
serializedName: "Balance";
};
nonce: {
type: number;
serializedType: number;
serializedName: "Nonce";
};
};
};
declare interface AccountData {
nonce?: BigIntLike;
balance?: BigIntLike;
storageRoot?: BufferLike;
codeHash?: BufferLike;
}
declare type AccountFields = Partial>;
declare type AccountFields_2 = Partial>;
declare class AccountManager {
#private;
constructor(blockchain: Blockchain);
get(address: Address, blockNumber?: Buffer | Tag): Promise;
getRaw(address: Address, blockNumber?: string | Buffer | Tag): Promise;
getNonce(address: Address, blockNumber?: QUANTITY | Buffer | Tag): Promise;
getBalance(address: Address, blockNumber?: QUANTITY | Buffer | Tag): Promise;
getNonceAndBalance(address: Address, blockNumber?: QUANTITY | Buffer | Tag): Promise<{
nonce: Quantity;
balance: Quantity;
}>;
getCode(address: Address, blockNumber?: QUANTITY | Buffer | Tag): Promise;
}
declare class AccountManager_2 extends Manager_2 {
#private;
static initialize(base: LevelUp, privateKeyManager: PrivateKeyManager, database: Database_2): Promise;
constructor(base: LevelUp, privateKeyManager: PrivateKeyManager, database: Database_2);
putAccount(account: Account_3): Promise;
getAccount(address: string): Promise;
/**
* Returns an array of accounts which we have private keys
* for. The order is the order in which they were stored.
* To add a controllable account, use `AccountManager.putAccount(account)`
* where `account.address.privateKey` is set.
*/
getControllableAccounts(): Promise>;
mintFunds(address: string, amount: bigint): Promise;
transferFunds(from: string, to: string, amount: bigint): Promise;
incrementNonce(address: string): Promise;
}
declare type AccountProof = {
address: Address;
balance: Quantity;
codeHash: Data;
nonce: Quantity;
storageHash: Data;
accountProof: Data[];
storageProof: StorageProof_2[];
};
declare type AccountState = [
balance: PrefixedHexString,
code: PrefixedHexString,
storage: Array
];
declare type AddOpcode = {
opcode: number;
opcodeName: string;
baseFee: number;
gasFunction?: AsyncDynamicGasHandler | SyncDynamicGasHandler;
logicFunction: OpHandler;
};
declare type AddPrecompile = {
address: Address_2;
function: PrecompileFunc;
};
declare class Address extends Address_2 {
static ByteLength: number;
constructor(value: Buffer);
static from(value: T): Address;
static toBuffer(value: JsonRpcDataInputArg): Buffer;
static toString(value: JsonRpcDataInputArg): string;
toJSON(): string;
}
declare class Address_2 {
readonly buf: Buffer;
constructor(buf: Buffer);
/**
* Returns the zero address.
*/
static zero(): Address_2;
/**
* Returns an Address object from a hex-encoded string.
* @param str - Hex-encoded address
*/
static fromString(str: string): Address_2;
/**
* Returns an address for a given public key.
* @param pubKey The two points of an uncompressed key
*/
static fromPublicKey(pubKey: Buffer): Address_2;
/**
* Returns an address for a given private key.
* @param privateKey A private key must be 256 bits wide
*/
static fromPrivateKey(privateKey: Buffer): Address_2;
/**
* Generates an address for a newly created contract.
* @param from The address which is creating this new address
* @param nonce The nonce of the from account
*/
static generate(from: Address_2, nonce: bigint): Address_2;
/**
* Generates an address for a contract created using CREATE2.
* @param from The address which is creating this new address
* @param salt A salt
* @param initCode The init code of the contract being created
*/
static generate2(from: Address_2, salt: Buffer, initCode: Buffer): Address_2;
/**
* Is address equal to another.
*/
equals(address: Address_2): boolean;
/**
* Is address zero.
*/
isZero(): boolean;
/**
* True if address is in the address range defined
* by EIP-1352
*/
isPrecompileOrSystemAddress(): boolean;
/**
* Returns hex encoding of address.
*/
toString(): string;
/**
* Returns Buffer representation of address.
*/
toBuffer(): Buffer;
}
declare class Address_3 extends SerializableLiteral {
#private;
get config(): {};
static readonly FirstNonSingletonActorId = 100;
static readonly FirstMinerId = 1000;
static readonly CHECKSUM_BYTES = 4;
static readonly CustomBase32Alphabet = "abcdefghijklmnopqrstuvwxyz234567";
get privateKey(): string | undefined;
get network(): AddressNetwork;
get protocol(): AddressProtocol;
constructor(publicAddress: string, privateKey?: string);
setPrivateKey(privateKey: string): void;
signProposal(proposal: StartDealParams): Promise;
signMessage(message: Message_2): Promise;
signBuffer(buffer: Buffer): Promise;
verifySignature(buffer: Buffer, signature: Signature): Promise;
static recoverBLSPublicKey(address: string): Buffer;
static recoverSECP256K1PublicKey(signature: Signature, message: Uint8Array): Buffer;
static fromPrivateKey(privateKey: string, protocol?: AddressProtocol, network?: AddressNetwork): Address_3;
static random(rng?: RandomNumberGenerator, protocol?: AddressProtocol, network?: AddressNetwork): Address_3;
static parseNetwork(publicAddress: string): AddressNetwork;
static parseProtocol(publicAddress: string): AddressProtocol;
/**
* Creates an AddressProtocol.ID address
* @param id - A positive integer for the id.
* @param isSingletonSystemActor - If false, it adds Address.FirstNonSingletonActorId to the id.
* Almost always `false`. See https://git.io/JtgqL for examples of singleton system actors.
* @param network - The AddressNetwork prefix for the address; usually AddressNetwork.Testnet for Ganache.
*/
static fromId(id: number, isSingletonSystemActor?: boolean, isMiner?: boolean, network?: AddressNetwork): Address_3;
static createChecksum(protocol: AddressProtocol, payload: Buffer): Buffer;
static validate(inputAddress: string): Address_3;
}
declare interface AddressConfig {
type: string;
}
/**
* A type that represents an input that can be converted to an Address.
*/
declare type AddressLike = Address_2 | Buffer | PrefixedHexString;
declare enum AddressNetwork {
Testnet = "t",
Mainnet = "f",
Unknown = "UNKNOWN"
}
declare enum AddressProtocol {
ID = 0,
SECP256K1 = 1,
Actor = 2,
BLS = 3,
Unknown = 255
}
declare interface AfterBlockEvent extends RunBlockResult {
block: Block_3;
}
declare interface AfterTxEvent extends RunTxResult {
/**
* The transaction which just got finished
*/
transaction: TypedTransaction_2;
}
/**
* Defines the interface for a API.
* All properties must be `async` callable or return a `Promise`
*/
declare interface Api extends ApiBase {
}
/**
* Base implementation for an API.
* All properties must be `async` callable or return a `Promise`
*/
declare class ApiBase {
readonly [index: string]: (...args: unknown[]) => Promise;
}
declare type ArrayToTuple> = T[number];
declare type AsCall = Flatten & {
readonly from?: string;
}>;
declare type AsPooled = Flatten & {
blockNumber: null;
blockHash: null;
transactionIndex: null;
}>;
/**
* This file returns the dynamic parts of opcodes which have dynamic gas
* These are not pure functions: some edit the size of the memory
* These functions are therefore not read-only
*/
declare interface AsyncDynamicGasHandler {
(runState: RunState, gas: bigint, common: Common): Promise;
}
declare class AsyncEventEmitter extends EventEmitter {
emit(event: E & string, ...args: Parameters): boolean;
once(event: E & string, listener: T[E]): this;
first(event: E & string, listener: T[E]): this;
before(event: E & string, target: T[E], listener: T[E]): this;
after(event: E & string, target: T[E], listener: T[E]): this;
private beforeOrAfter;
on(event: E & string, listener: T[E]): this;
addListener(event: E & string, listener: T[E]): this;
prependListener(event: E & string, listener: T[E]): this;
prependOnceListener(event: E & string, listener: T[E]): this;
removeAllListeners(event?: keyof T & string): this;
removeListener(event: E & string, listener: T[E]): this;
eventNames(): Array;
listeners(event: E & string): Array;
listenerCount(event: keyof T & string): number;
getMaxListeners(): number;
setMaxListeners(maxListeners: number): this;
}
declare type AsyncListener = ((data: T, callback?: (result?: R) => void) => Promise) | ((data: T, callback?: (result?: R) => void) => void);
declare interface AsyncOpHandler {
(runState: RunState, common: Common): Promise;
}
declare class Balance extends SerializableLiteral {
get config(): LiteralDefinition;
sub(val: string | number | bigint): void;
add(val: string | number | bigint): void;
toFIL(): number;
static FILToLowestDenomination(fil: number): bigint;
static LowestDenominationToFIL(attoFil: bigint): number;
}
declare interface BalanceConfig {
type: bigint;
}
declare namespace Base {
type Option = {
rawType?: unknown;
type: unknown;
hasDefault?: true;
legacy?: {
[name: string]: unknown;
};
cliType?: CliTypes;
};
type ExclusiveGroupOptionName = string;
type ExclusiveGroup = ExclusiveGroupOptionName[];
type Config = {
options: {
[optionName: string]: Option;
};
exclusiveGroups?: ExclusiveGroup[];
};
}
declare type BaseConfig = {
properties: {
[deserializedName: string]: {
type: any;
serializedName: string;
serializedType: any;
};
};
};
declare type BaseConfig_2 = {
type: number | string | Buffer | bigint | null;
};
declare type BaseFeeHeader = BlockHeader & Required>;
declare type BaseFilterArgs = {
address?: string | string[];
topics?: Topic[];
};
declare class BaseJsonRpcType {
protected bufferValue: Buffer | null;
private [inspect];
constructor(value: JsonRpcInputArg);
toString(): string | null;
toBuffer(): Buffer;
valueOf(): any;
toJSON(): string | null;
isNull(): boolean;
}
declare interface BaseOpts {
/**
* String identifier ('byzantium') for hardfork or {@link Hardfork} enum.
*
* Default: Hardfork.London
*/
hardfork?: string | Hardfork_2;
/**
* Selected EIPs which can be activated, please use an array for instantiation
* (e.g. `eips: [ 2537, ]`)
*
* Currently supported:
*
* - [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) - BLS12-381 precompiles
*/
eips?: number[];
}
declare class BaseTransaction {
type: Quantity;
nonce: Quantity;
gas: Quantity;
to: Address;
value: Quantity;
data: Data;
v: Quantity | null;
r: Quantity | null;
s: Quantity | null;
effectiveGasPrice: Quantity;
from: Address | null;
common: Common;
index: Quantity;
hash: Data;
blockNumber: Quantity;
blockHash: Data;
constructor(common: Common, extra?: GanacheRawExtraTx);
setExtra(raw: GanacheRawExtraTx): void;
calculateIntrinsicGas(): bigint;
}
/**
* This base class will likely be subject to further
* refactoring along the introduction of additional tx types
* on the Ethereum network.
*
* It is therefore not recommended to use directly.
*/
declare abstract class BaseTransaction_2 {
private readonly _type;
readonly nonce: bigint;
readonly gasLimit: bigint;
readonly to?: Address_2;
readonly value: bigint;
readonly data: Buffer;
readonly v?: bigint;
readonly r?: bigint;
readonly s?: bigint;
readonly common: Common;
protected cache: TransactionCache;
protected readonly txOptions: TxOptions;
/**
* List of tx type defining EIPs,
* e.g. 1559 (fee market) and 2930 (access lists)
* for FeeMarketEIP1559Transaction objects
*/
protected activeCapabilities: number[];
/**
* The default chain the tx falls back to if no Common
* is provided and if the chain can't be derived from
* a passed in chainId (only EIP-2718 typed txs) or
* EIP-155 signature (legacy txs).
*
* @hidden
*/
protected DEFAULT_CHAIN: Chain;
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
protected DEFAULT_HARDFORK: string | Hardfork_2;
constructor(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData, opts: TxOptions);
/**
* Returns the transaction type.
*
* Note: legacy txs will return tx type `0`.
*/
get type(): number;
/**
* Checks if a tx type defining capability is active
* on a tx, for example the EIP-1559 fee market mechanism
* or the EIP-2930 access list feature.
*
* Note that this is different from the tx type itself,
* so EIP-2930 access lists can very well be active
* on an EIP-1559 tx for example.
*
* This method can be useful for feature checks if the
* tx type is unknown (e.g. when instantiated with
* the tx factory).
*
* See `Capabilites` in the `types` module for a reference
* on all supported capabilities.
*/
supports(capability: Capability_2): boolean;
/**
* Checks if the transaction has the minimum amount of gas required
* (DataFee + TxFee + Creation Fee).
*/
validate(): boolean;
validate(stringError: false): boolean;
validate(stringError: true): string[];
protected _validateYParity(): void;
/**
* EIP-2: All transaction signatures whose s-value is greater than secp256k1n/2are considered invalid.
* Reasoning: https://ethereum.stackexchange.com/a/55728
*/
protected _validateHighS(): void;
/**
* The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)
*/
getBaseFee(): bigint;
/**
* The amount of gas paid for the data in this tx
*/
getDataFee(): bigint;
/**
* The up front amount that an account must have for this transaction to be valid
*/
abstract getUpfrontCost(): bigint;
/**
* If the tx's `to` is to the creation address
*/
toCreationAddress(): boolean;
/**
* Returns a Buffer Array of the raw Buffers of this transaction, in order.
*
* Use {@link BaseTransaction.serialize} to add a transaction to a block
* with {@link Block.fromValuesArray}.
*
* For an unsigned tx this method uses the empty Buffer values for the
* signature parameters `v`, `r` and `s` for encoding. For an EIP-155 compliant
* representation for external signing use {@link BaseTransaction.getMessageToSign}.
*/
abstract raw(): TxValuesArray | AccessListEIP2930ValuesArray | FeeMarketEIP1559ValuesArray;
/**
* Returns the encoding of the transaction.
*/
abstract serialize(): Buffer;
abstract getMessageToSign(hashMessage: false): Buffer | Buffer[];
abstract getMessageToSign(hashMessage?: true): Buffer;
abstract hash(): Buffer;
abstract getMessageToVerifySignature(): Buffer;
isSigned(): boolean;
/**
* Determines if the signature is valid
*/
verifySignature(): boolean;
/**
* Returns the sender's address
*/
getSenderAddress(): Address_2;
/**
* Returns the public key of the sender
*/
abstract getSenderPublicKey(): Buffer;
/**
* Signs a transaction.
*
* Note that the signed tx is returned as a new object,
* use as follows:
* ```javascript
* const signedTx = tx.sign(privateKey)
* ```
*/
sign(privateKey: Buffer): TransactionObject;
/**
* Returns an object with the JSON representation of the transaction
*/
abstract toJSON(): JsonTx;
protected abstract _processSignature(v: bigint, r: Buffer, s: Buffer): TransactionObject;
/**
* Does chain ID checks on common and returns a common
* to be used on instantiation
* @hidden
*
* @param common - {@link Common} instance from tx options
* @param chainId - Chain ID from tx options (typed txs) or signature (legacy tx)
*/
protected _getCommon(common?: Common, chainId?: BigIntLike): Common;
/**
* Validates that an object with BigInt values cannot exceed the specified bit limit.
* @param values Object containing string keys and BigInt values
* @param bits Number of bits to check (64 or 256)
* @param cannotEqual Pass true if the number also cannot equal one less the maximum value
*/
protected _validateCannotExceedMaxInteger(values: {
[key: string]: bigint | undefined;
}, bits?: number, cannotEqual?: boolean): void;
protected static _validateNotArray(values: {
[key: string]: any;
}): void;
/**
* Return a compact error string representation of the object
*/
abstract errorStr(): string;
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected abstract _errorMsg(msg: string): string;
/**
* Returns the shared error postfix part for _error() method
* tx type implementations.
*/
protected _getSharedErrorPostfix(): string;
}
/**
* Abstract interface with common transaction receipt fields
*/
declare interface BaseTxReceipt {
/**
* Cumulative gas used in the block including this tx
*/
cumulativeBlockGasUsed: bigint;
/**
* Bloom bitvector
*/
bitvector: Buffer;
/**
* Logs emitted
*/
logs: Log[];
}
declare type BatchDBOp = PutBatch_2 | DelBatch_2;
declare interface BatchedCallback {
(err?: Error, response?: (JsonRpcResponse | JsonRpcError)[]): void;
}
declare class BeaconEntry extends SerializableObject implements DeserializedObject {
get config(): Definitions;
constructor(options?: Partial> | Partial>);
round: number;
data: Buffer;
}
declare interface BeaconEntryConfig {
properties: {
round: {
type: number;
serializedType: number;
serializedName: "Round";
};
data: {
type: Buffer;
serializedType: string;
serializedName: "Data";
};
};
}
declare type BigIntLike = bigint | PrefixedHexString | number | Buffer;
declare class Block {
/**
* Base fee per gas for blocks without a parent containing a base fee per gas.
*/
static readonly INITIAL_BASE_FEE_PER_GAS: 1000000000n;
protected _size: number;
protected _raw: EthereumRawBlockHeader;
protected _common: Common;
protected _rawTransactions: TypedDatabaseTransaction[];
protected _rawTransactionMetaData: GanacheRawBlockTransactionMetaData[];
header: BlockHeader;
constructor(serialized: Buffer, common: Common);
private _hash;
hash(): Data;
getTransactions(): (LegacyTransaction | EIP2930AccessListTransaction | EIP1559FeeMarketTransaction)[];
toJSON(includeFullTransactions: IncludeTransactions): {
size: Quantity;
transactions: IncludeTransactions extends true ? TypedTransactionJSON[] : Data[];
uncles: Data[];
parentHash: Data;
sha3Uncles: Data;
miner: Data;
stateRoot: Data;
transactionsRoot: Data;
receiptsRoot: Data;
logsBloom: Data;
difficulty: Quantity;
totalDifficulty: Quantity;
number: Quantity;
gasLimit: Quantity;
gasUsed: Quantity;
timestamp: Quantity;
extraData: Data;
mixHash: Data;
nonce: Data;
baseFeePerGas?: Quantity;
hash: Data;
};
getTxFn(include?: IncludeTransactions): (tx: TypedTransaction) => ReturnType | Data;
static fromParts(rawHeader: EthereumRawBlockHeader, txs: TypedDatabaseTransaction[], totalDifficulty: Buffer, extraTxs: GanacheRawBlockTransactionMetaData[], size: number, common: Common): Block;
static calcNextBaseFeeBigInt(parentHeader: BaseFeeHeader): bigint;
static calcNBlocksMaxBaseFee(blocks: number, parentHeader: BaseFeeHeader): bigint;
static calcNextBaseFee(parentBlock: Block): bigint;
}
declare type Block_2 = {
header: {
number: bigint;
cliqueSigner(): Address_2;
coinbase: Address_2;
timestamp: bigint;
difficulty: bigint;
prevRandao: Buffer;
gasLimit: bigint;
baseFeePerGas?: bigint;
};
};
/**
* An object that represents the block.
*/
declare class Block_3 {
readonly header: BlockHeader_2;
readonly transactions: TypedTransaction_2[];
readonly uncleHeaders: BlockHeader_2[];
readonly txTrie: Trie;
readonly _common: Common;
/**
* Static constructor to create a block from a block data dictionary
*
* @param blockData
* @param opts
*/
static fromBlockData(blockData?: BlockData, opts?: BlockOptions): Block_3;
/**
* Static constructor to create a block from a RLP-serialized block
*
* @param serialized
* @param opts
*/
static fromRLPSerializedBlock(serialized: Buffer, opts?: BlockOptions): Block_3;
/**
* Static constructor to create a block from an array of Buffer values
*
* @param values
* @param opts
*/
static fromValuesArray(values: BlockBuffer, opts?: BlockOptions): Block_3;
/**
* Creates a new block object from Ethereum JSON RPC.
*
* @param blockParams - Ethereum JSON RPC of block (eth_getBlockByNumber)
* @param uncles - Optional list of Ethereum JSON RPC of uncles (eth_getUncleByBlockHashAndIndex)
* @param options - An object describing the blockchain
*/
static fromRPC(blockData: JsonRpcBlock, uncles?: any[], opts?: BlockOptions): Block_3;
/**
* Method to retrieve a block from the provider and format as a {@link Block}
* @param provider an Ethers JsonRPCProvider
* @param blockTag block hash or block number to be run
* @param opts {@link BlockOptions}
* @returns the block specified by `blockTag`
*/
static fromEthersProvider: (provider: ethers.providers.JsonRpcProvider | string, blockTag: string | bigint, opts: BlockOptions) => Promise;
/**
* This constructor takes the values, validates them, assigns them and freezes the object.
* Use the static factory methods to assist in creating a Block object from varying data types and options.
*/
constructor(header?: BlockHeader_2, transactions?: TypedTransaction_2[], uncleHeaders?: BlockHeader_2[], opts?: BlockOptions);
/**
* Returns a Buffer Array of the raw Buffers of this block, in order.
*/
raw(): BlockBuffer;
/**
* Returns the hash of the block.
*/
hash(): Buffer;
/**
* Determines if this block is the genesis block.
*/
isGenesis(): boolean;
/**
* Returns the rlp encoding of the block.
*/
serialize(): Buffer;
/**
* Generates transaction trie for validation.
*/
genTxTrie(): Promise;
/**
* Validates the transaction trie by generating a trie
* and do a check on the root hash.
*/
validateTransactionsTrie(): Promise;
/**
* Validates transaction signatures and minimum gas requirements.
*
* @param stringError - If `true`, a string with the indices of the invalid txs is returned.
*/
validateTransactions(): boolean;
validateTransactions(stringError: false): boolean;
validateTransactions(stringError: true): string[];
/**
* Validates the block data, throwing if invalid.
* This can be checked on the Block itself without needing access to any parent block
* It checks:
* - All transactions are valid
* - The transactions trie is valid
* - The uncle hash is valid
* @param onlyHeader if only passed the header, skip validating txTrie and unclesHash (default: false)
*/
validateData(onlyHeader?: boolean): Promise;
/**
* Validates the uncle's hash.
*/
validateUnclesHash(): boolean;
/**
* Consistency checks for uncles included in the block, if any.
*
* Throws if invalid.
*
* The rules for uncles checked are the following:
* Header has at most 2 uncles.
* Header does not count an uncle twice.
*/
validateUncles(): void;
/**
* Returns the canonical difficulty for this block.
*
* @param parentBlock - the parent of this `Block`
*/
ethashCanonicalDifficulty(parentBlock: Block_3): bigint;
/**
* Validates if the block gasLimit remains in the boundaries set by the protocol.
* Throws if invalid
*
* @param parentBlock - the parent of this `Block`
*/
validateGasLimit(parentBlock: Block_3): void;
/**
* Returns the block in JSON format.
*/
toJSON(): JsonBlock;
/**
* Return a compact error string representation of the object
*/
errorStr(): string;
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string): string;
}
declare type BlockBodyBuffer = [TransactionsBuffer, UncleHeadersBuffer];
declare type BlockBuffer = [BlockHeaderBuffer, TransactionsBuffer, UncleHeadersBuffer];
declare class BlockBuilder {
/**
* The cumulative gas used by the transactions added to the block.
*/
gasUsed: bigint;
private readonly vm;
private blockOpts;
private headerData;
private transactions;
private transactionResults;
private checkpointed;
private reverted;
private built;
get transactionReceipts(): TxReceipt[];
constructor(vm: VM, opts: BuildBlockOpts);
/**
* Throws if the block has already been built or reverted.
*/
private checkStatus;
/**
* Calculates and returns the transactionsTrie for the block.
*/
transactionsTrie(): Promise;
/**
* Calculates and returns the logs bloom for the block.
*/
logsBloom(): Buffer;
/**
* Calculates and returns the receiptTrie for the block.
*/
receiptTrie(): Promise;
/**
* Adds the block miner reward to the coinbase account.
*/
private rewardMiner;
/**
* Run and add a transaction to the block being built.
* Please note that this modifies the state of the VM.
* Throws if the transaction's gasLimit is greater than
* the remaining gas in the block.
*/
addTransaction(tx: TypedTransaction_2): Promise;
/**
* Reverts the checkpoint on the StateManager to reset the state from any transactions that have been run.
*/
revert(): Promise;
/**
* This method returns the finalized block.
* It also:
* - Assigns the reward for miner (PoW)
* - Commits the checkpoint on the StateManager
* - Sets the tip of the VM's blockchain to this block
* For PoW, optionally seals the block with params `nonce` and `mixHash`,
* which is validated along with the block number and difficulty by ethash.
* For PoA, please pass `blockOption.cliqueSigner` into the buildBlock constructor,
* as the signer will be awarded the txs amount spent on gas as they are added.
*/
build(sealOpts?: SealBlockOpts): Promise;
}
declare class Blockchain extends Emittery {
#private;
blocks: BlockManager;
blockLogs: BlockLogManager;
transactions: TransactionManager;
transactionReceipts: TransactionReceiptManager;
storageKeys: Database["storageKeys"];
accounts: AccountManager;
vm: VM;
trie: GanacheTrie;
common: Common;
fallback: Fork;
/**
* Initializes the underlying Database and handles synchronization between
* the API and the database.
*
* Emits a `ready` event once the database and all dependencies are fully
* initialized.
* @param options -
*/
constructor(options: EthereumInternalOptions, coinbase: Address, fallback?: Fork);
initialize(initialAccounts: Account[]): Promise;
coinbase: Address;
getMixHash(data: Buffer): Buffer;
isStarted: () => boolean;
mine: (maxTransactions: number | Capacity, onlyOneBlock?: boolean, timestamp?: number) => Promise<{
transactions: TypedTransaction[];
blockNumber: bigint;
}>;
pause(): void;
resume(_threads?: number): Promise<{
transactions: TypedTransaction[];
blockNumber: bigint;
}>;
createVmFromStateTrie: (stateTrie: GanacheTrie | ForkTrie, allowUnlimitedContractSize: boolean, activatePrecompile: boolean, common?: Common) => Promise;
/**
* @param milliseconds - the number of milliseconds to adjust the time by.
* Negative numbers are treated as 0.
* @returns the total time offset *in milliseconds*
*/
increaseTime(milliseconds: number): number;
/**
* Adjusts the internal time adjustment such that the provided time is considered the "current" time.
* @param newTime - the time (in milliseconds) that will be considered the "current" time
* @returns the total time offset *in milliseconds*
*/
setTimeDiff(newTime: number): number;
snapshot(): number;
revert(snapshotId: Quantity): Promise;
queueTransaction(transaction: TypedTransaction, secretKey?: Data): Promise;
simulateTransaction(transaction: SimulationTransaction, parentBlock: Block, overrides: CallOverrides): Promise;
isPostMerge: boolean;
/**
* traceTransaction
*
* Run a previously-run transaction in the same state in which it occurred at the time it was run.
* This will return the vm-level trace output for debugging purposes.
*
* Strategy:
*
* 1. Find block where transaction occurred
* 2. Set state root of that block
* 3. Rerun every transaction in that block prior to and including the requested transaction
* 4. Send trace results back.
*
* @param transactionHash -
* @param options -
*/
traceTransaction(transactionHash: string, options: TraceTransactionOptions): Promise<{
gas: Quantity;
structLogs: StructLog[];
returnValue: string;
storage: Record;
}>;
/**
* storageRangeAt
*
* Returns a contract's storage given a starting key and max number of
* entries to return.
*
*
* @param blockHash -
* @param txIndex -
* @param contractAddress -
* @param startKey -
* @param maxResult -
*/
storageRangeAt(blockHash: string, txIndex: number, contractAddress: string, startKey: string, maxResult: number): Promise;
toggleStepEvent(enable: boolean): void;
/**
* Gracefully shuts down the blockchain service and all of its dependencies.
*/
stop(): Promise;
}
/**
* This class stores and interacts with blocks.
*/
declare class Blockchain_2 implements BlockchainInterface {
consensus: Consensus;
db: AbstractLevel;
dbManager: DBManager;
private _genesisBlock?; /** The genesis block of this blockchain */
private _customGenesisState?; /** Custom genesis state */
/**
* The following two heads and the heads stored within the `_heads` always point
* to a hash in the canonical chain and never to a stale hash.
* With the exception of `_headHeaderHash` this does not necessarily need to be
* the hash with the highest total difficulty.
*/
/** The hash of the current head block */
private _headBlockHash?;
/** The hash of the current head header */
private _headHeaderHash?;
/**
* A Map which stores the head of each key (for instance the "vm" key) which is
* updated along a {@link Blockchain.iterator} method run and can be used to (re)run
* non-verified blocks (for instance in the VM).
*/
private _heads;
protected _isInitialized: boolean;
private _lock;
_common: Common;
private _hardforkByHeadBlockNumber;
private readonly _validateConsensus;
private readonly _validateBlocks;
/**
* Safe creation of a new Blockchain object awaiting the initialization function,
* encouraged method to use when creating a blockchain object.
*
* @param opts Constructor options, see {@link BlockchainOptions}
*/
static create(opts?: BlockchainOptions): Promise;
/**
* Creates a blockchain from a list of block objects,
* objects must be readable by {@link Block.fromBlockData}
*
* @param blockData List of block objects
* @param opts Constructor options, see {@link BlockchainOptions}
*/
static fromBlocksData(blocksData: BlockData[], opts?: BlockchainOptions): Promise;
/**
* Creates new Blockchain object.
*
* @deprecated The direct usage of this constructor is discouraged since
* non-finalized async initialization might lead to side effects. Please
* use the async {@link Blockchain.create} constructor instead (same API).
*
* @param opts An object with the options that this constructor takes. See
* {@link BlockchainOptions}.
*/
protected constructor(opts?: BlockchainOptions);
/**
* Returns a deep copy of this {@link Blockchain} instance.
*
* Note: this does not make a copy of the underlying db
* since it is unknown if the source is on disk or in memory.
* This should not be a significant issue in most usage since
* the queries will only reflect the instance's known data.
* If you would like this copied blockchain to use another db
* set the {@link db} of this returned instance to a copy of
* the original.
*/
copy(): Blockchain_2;
/**
* This method is called in {@link Blockchain.create} and either sets up the DB or reads
* values from the DB and makes these available to the consumers of
* Blockchain.
*
* @hidden
*/
private _init;
/**
* Run a function after acquiring a lock. It is implied that we have already
* initialized the module (or we are calling this from the init function, like
* `_setCanonicalGenesisBlock`)
* @param action - function to run after acquiring a lock
* @hidden
*/
private runWithLock;
/**
* Returns the specified iterator head.
*
* This function replaces the old {@link Blockchain.getHead} method. Note that
* the function deviates from the old behavior and returns the
* genesis hash instead of the current head block if an iterator
* has not been run. This matches the behavior of {@link Blockchain.iterator}.
*
* @param name - Optional name of the iterator head (default: 'vm')
*/
getIteratorHead(name?: string): Promise;
/**
* Returns the specified iterator head.
*
* @param name - Optional name of the iterator head (default: 'vm')
*
* @deprecated use {@link Blockchain.getIteratorHead} instead.
* Note that {@link Blockchain.getIteratorHead} doesn't return
* the `headHeader` but the genesis hash as an initial iterator
* head value (now matching the behavior of {@link Blockchain.iterator}
* on a first run)
*/
getHead(name?: string): Promise;
/**
* Returns the latest header in the canonical chain.
*/
getCanonicalHeadHeader(): Promise;
/**
* Returns the latest full block in the canonical chain.
*/
getCanonicalHeadBlock(): Promise;
/**
* Adds blocks to the blockchain.
*
* If an invalid block is met the function will throw, blocks before will
* nevertheless remain in the DB. If any of the saved blocks has a higher
* total difficulty than the current max total difficulty the canonical
* chain is rebuilt and any stale heads/hashes are overwritten.
* @param blocks - The blocks to be added to the blockchain
*/
putBlocks(blocks: Block_3[]): Promise;
/**
* Adds a block to the blockchain.
*
* If the block is valid and has a higher total difficulty than the current
* max total difficulty, the canonical chain is rebuilt and any stale
* heads/hashes are overwritten.
* @param block - The block to be added to the blockchain
*/
putBlock(block: Block_3): Promise;
/**
* Adds many headers to the blockchain.
*
* If an invalid header is met the function will throw, headers before will
* nevertheless remain in the DB. If any of the saved headers has a higher
* total difficulty than the current max total difficulty the canonical
* chain is rebuilt and any stale heads/hashes are overwritten.
* @param headers - The headers to be added to the blockchain
*/
putHeaders(headers: Array): Promise;
/**
* Adds a header to the blockchain.
*
* If this header is valid and it has a higher total difficulty than the current
* max total difficulty, the canonical chain is rebuilt and any stale
* heads/hashes are overwritten.
* @param header - The header to be added to the blockchain
*/
putHeader(header: BlockHeader_2): Promise;
/**
* Entrypoint for putting any block or block header. Verifies this block,
* checks the total TD: if this TD is higher than the current highest TD, we
* have thus found a new canonical block and have to rewrite the canonical
* chain. This also updates the head block hashes. If any of the older known
* canonical chains just became stale, then we also reset every _heads header
* which points to a stale header to the last verified header which was in the
* old canonical chain, but also in the new canonical chain. This thus rolls
* back these headers so that these can be updated to the "new" canonical
* header using the iterator method.
* @hidden
*/
private _putBlockOrHeader;
/**
* Validates a block header, throwing if invalid. It is being validated against the reported `parentHash`.
* It verifies the current block against the `parentHash`:
* - The `parentHash` is part of the blockchain (it is a valid header)
* - Current block number is parent block number + 1
* - Current block has a strictly higher timestamp
* - Additional PoW checks ->
* - Current block has valid difficulty and gas limit
* - In case that the header is an uncle header, it should not be too old or young in the chain.
* - Additional PoA clique checks ->
* - Checks on coinbase and mixHash
* - Current block has a timestamp diff greater or equal to PERIOD
* - Current block has difficulty correctly marked as INTURN or NOTURN
* @param header - header to be validated
* @param height - If this is an uncle header, this is the height of the block that is including it
*/
validateHeader(header: BlockHeader_2, height?: bigint): Promise;
/**
* Validates a block, by validating the header against the current chain, any uncle headers, and then
* whether the block is internally consistent
* @param block block to be validated
*/
validateBlock(block: Block_3): Promise;
/**
* The following rules are checked in this method:
* Uncle Header is a valid header.
* Uncle Header is an orphan, i.e. it is not one of the headers of the canonical chain.
* Uncle Header has a parentHash which points to the canonical chain. This parentHash is within the last 7 blocks.
* Uncle Header is not already included as uncle in another block.
* @param block - block for which uncles are being validated
*/
private _validateUncleHeaders;
/**
* Gets a block by its hash or number. If a number is provided, the returned
* block will be the canonical block at that number in the chain
*
* @param blockId - The block's hash or number. If a hash is provided, then
* this will be immediately looked up, otherwise it will wait until we have
* unlocked the DB
*/
getBlock(blockId: Buffer | number | bigint): Promise;
/**
* Gets total difficulty for a block specified by hash and number
*/
getTotalDifficulty(hash: Buffer, number?: bigint): Promise;
/**
* Looks up many blocks relative to blockId Note: due to `GetBlockHeaders
* (0x03)` (ETH wire protocol) we have to support skip/reverse as well.
* @param blockId - The block's hash or number
* @param maxBlocks - Max number of blocks to return
* @param skip - Number of blocks to skip apart
* @param reverse - Fetch blocks in reverse
*/
getBlocks(blockId: Buffer | bigint | number, maxBlocks: number, skip: number, reverse: boolean): Promise;
/**
* Given an ordered array, returns an array of hashes that are not in the
* blockchain yet. Uses binary search to find out what hashes are missing.
* Therefore, the array needs to be ordered upon number.
* @param hashes - Ordered array of hashes (ordered on `number`).
*/
selectNeededHashes(hashes: Array): Promise;
/**
* Completely deletes a block from the blockchain including any references to
* this block. If this block was in the canonical chain, then also each child
* block of this block is deleted Also, if this was a canonical block, each
* head header which is part of this now stale chain will be set to the
* parentHeader of this block An example reason to execute is when running the
* block in the VM invalidates this block: this will then reset the canonical
* head to the past block (which has been validated in the past by the VM, so
* we can be sure it is correct).
* @param blockHash - The hash of the block to be deleted
*/
delBlock(blockHash: Buffer): Promise;
/**
* @hidden
*/
private _delBlock;
/**
* Updates the `DatabaseOperation` list to delete a block from the DB,
* identified by `blockHash` and `blockNumber`. Deletes fields from `Header`,
* `Body`, `HashToNumber` and `TotalDifficulty` tables. If child blocks of
* this current block are in the canonical chain, delete these as well. Does
* not actually commit these changes to the DB. Sets `_headHeaderHash` and
* `_headBlockHash` to `headHash` if any of these matches the current child to
* be deleted.
* @param blockHash - the block hash to delete
* @param blockNumber - the number corresponding to the block hash
* @param headHash - the current head of the chain (if null, do not update
* `_headHeaderHash` and `_headBlockHash`)
* @param ops - the `DatabaseOperation` list to add the delete operations to
* @hidden
*/
private _delChild;
/**
* Iterates through blocks starting at the specified iterator head and calls
* the onBlock function on each block. The current location of an iterator
* head can be retrieved using {@link Blockchain.getIteratorHead}.
*
* @param name - Name of the state root head
* @param onBlock - Function called on each block with params (block, reorg)
* @param maxBlocks - How many blocks to run. By default, run all unprocessed blocks in the canonical chain.
* @param releaseLockOnCallback - Do not lock the blockchain for running the callback (default: `false`)
* @returns number of blocks actually iterated
*/
iterator(name: string, onBlock: OnBlock, maxBlocks?: number, releaseLockOnCallback?: boolean): Promise;
/**
* Set header hash of a certain `tag`.
* When calling the iterator, the iterator will start running the first child block after the header hash currently stored.
* @param tag - The tag to save the headHash to
* @param headHash - The head hash to save
*/
setIteratorHead(tag: string, headHash: Buffer): Promise;
/**
* Find the common ancestor of the new block and the old block.
* @param newHeader - the new block header
*/
private findCommonAncestor;
/**
* Pushes DB operations to delete canonical number assignments for specified
* block number and above. This only deletes `NumberToHash` references and not
* the blocks themselves. Note: this does not write to the DB but only pushes
* to a DB operations list.
* @param blockNumber - the block number from which we start deleting
* canonical chain assignments (including this block)
* @param headHash - the hash of the current canonical chain head. The _heads
* reference matching any hash of any of the deleted blocks will be set to
* this
* @param ops - the DatabaseOperation list to write DatabaseOperations to
* @hidden
*/
private _deleteCanonicalChainReferences;
/**
* Given a `header`, put all operations to change the canonical chain directly
* into `ops`. This walks the supplied `header` backwards. It is thus assumed
* that this header should be canonical header. For each header the
* corresponding hash corresponding to the current canonical chain in the DB
* is checked. If the number => hash reference does not correspond to the
* reference in the DB, we overwrite this reference with the implied number =>
* hash reference Also, each `_heads` member is checked; if these point to a
* stale hash, then the hash which we terminate the loop (i.e. the first hash
* which matches the number => hash of the implied chain) is put as this stale
* head hash. The same happens to _headBlockHash.
* @param header - The canonical header.
* @param ops - The database operations list.
* @hidden
*/
private _rebuildCanonical;
/**
* Builds the `DatabaseOperation[]` list which describes the DB operations to
* write the heads, head header hash and the head header block to the DB
* @hidden
*/
private _saveHeadOps;
/**
* Gets the `DatabaseOperation[]` list to save `_heads`, `_headHeaderHash` and
* `_headBlockHash` and writes these to the DB
* @hidden
*/
private _saveHeads;
/**
* Gets a header by hash and number. Header can exist outside the canonical
* chain
*
* @hidden
*/
private _getHeader;
protected checkAndTransitionHardForkByNumber(number: bigint, td?: BigIntLike): void;
/**
* Gets a header by number. Header must be in the canonical chain
*/
getCanonicalHeader(number: bigint): Promise;
/**
* This method either returns a Buffer if there exists one in the DB or if it
* does not exist (DB throws a `NotFoundError`) then return false If DB throws
* any other error, this function throws.
* @param number
*/
safeNumberToHash(number: bigint): Promise;
/**
* The genesis {@link Block} for the blockchain.
*/
get genesisBlock(): Block_3;
/**
* Creates a genesis {@link Block} for the blockchain with params from {@link Common.genesis}
* @param stateRoot The genesis stateRoot
*/
createGenesisBlock(stateRoot: Buffer): Block_3;
/**
* Returns the genesis state of the blockchain.
* All values are provided as hex-prefixed strings.
*/
genesisState(): GenesisState;
}
declare class Blockchain_3 extends Emittery {
#private;
tipsetManager: TipsetManager | null;
blockHeaderManager: BlockHeaderManager | null;
accountManager: AccountManager_2 | null;
privateKeyManager: PrivateKeyManager | null;
signedMessagesManager: SignedMessageManager | null;
blockMessagesManager: BlockMessagesManager | null;
dealInfoManager: DealInfoManager | null;
readonly miner: Address_3;
get minerEnabled(): boolean;
messagePool: Array;
readonly options: FilecoinInternalOptions;
private ipfsServer;
private miningTimeout;
private rng;
get dbDirectory(): string | null;
private ready;
private stopped;
constructor(options: FilecoinInternalOptions);
initialize(): Promise;
waitForReady(): Promise;
/**
* Gracefully shuts down the blockchain service and all of its dependencies.
*/
stop(): Promise;
get ipfs(): any | null;
private intervalMine;
enableMiner(): Promise;
disableMiner(): Promise;
genesisTipset(): Tipset;
latestTipset(): Tipset;
push(message: Message_2, spec: MessageSendSpec): Promise;
pushSigned(signedMessage: SignedMessage, acquireLock?: boolean): Promise;
mpoolClear(local: boolean): Promise;
mpoolPending(): Promise>;
mineTipset(numNewBlocks?: number): Promise;
hasLocal(cid: string): Promise;
private getIPFSObjectSize;
private downloadFile;
startDeal(proposal: StartDealParams): Promise;
createQueryOffer(rootCid: RootCID): Promise;
retrieve(retrievalOrder: RetrievalOrder, ref: FileRef): Promise;
getTipsetFromKey(tipsetKey?: Array): Promise;
getTipsetByHeight(height: number, tipsetKey?: Array): Promise;
createAccount(protocol: AddressProtocol): Promise;
private logLatestTipset;
}
declare type BlockchainEvents = {
ready: undefined;
tipset: Tipset;
minerEnabled: boolean;
dealUpdate: DealInfo;
};
declare interface BlockchainInterface {
consensus: Consensus;
/**
* Adds a block to the blockchain.
*
* @param block - The block to be added to the blockchain.
*/
putBlock(block: Block_3): Promise;
/**
* Deletes a block from the blockchain. All child blocks in the chain are
* deleted and any encountered heads are set to the parent block.
*
* @param blockHash - The hash of the block to be deleted
*/
delBlock(blockHash: Buffer): Promise;
/**
* Returns a block by its hash or number.
*/
getBlock(blockId: Buffer | number | bigint): Promise;
/**
* Iterates through blocks starting at the specified iterator head and calls
* the onBlock function on each block.
*
* @param name - Name of the state root head
* @param onBlock - Function called on each block with params (block: Block,
* @param maxBlocks - optional maximum number of blocks to iterate through
* reorg: boolean)
*/
iterator(name: string, onBlock: OnBlock, maxBlocks?: number, releaseLockOnCallback?: boolean): Promise;
/**
* Returns a copy of the blockchain
*/
copy(): BlockchainInterface;
/**
* Validates a block header, throwing if invalid. It is being validated against the reported `parentHash`.
* @param header - header to be validated
* @param height - If this is an uncle header, this is the height of the block that is including it
*/
validateHeader(header: BlockHeader_2, height?: bigint): Promise;
/**
* Returns the specified iterator head.
*
* @param name - Optional name of the iterator head (default: 'vm')
*/
getIteratorHead?(name?: string): Promise;
/**
* Gets total difficulty for a block specified by hash and number
*/
getTotalDifficulty?(hash: Buffer, number?: bigint): Promise;
/**
* Returns the genesis state of the blockchain.
* All values are provided as hex-prefixed strings.
*/
genesisState?(): GenesisState;
/**
* Returns the latest full block in the canonical chain.
*/
getCanonicalHeadBlock?(): Promise;
}
/**
* This are the options that the Blockchain constructor can receive.
*/
declare interface BlockchainOptions {
/**
* Specify the chain and hardfork by passing a {@link Common} instance.
*
* If not provided this defaults to chain `mainnet` and hardfork `chainstart`
*
*/
common?: Common;
/**
* Set the HF to the fork determined by the head block and update on head updates.
*
* Note: for HFs where the transition is also determined by a total difficulty
* threshold (merge HF) the calculated TD is additionally taken into account
* for HF determination.
*
* Default: `false` (HF is set to whatever default HF is set by the {@link Common} instance)
*/
hardforkByHeadBlockNumber?: boolean;
/**
* Database to store blocks and metadata.
* Should be an `abstract-leveldown` compliant store
* wrapped with `encoding-down`.
* For example:
* `levelup(encode(leveldown('./db1')))`
* or use the `level` convenience package:
* `new MemoryLevel('./db1')`
*/
db?: AbstractLevel;
/**
* This flags indicates if a block should be validated along the consensus algorithm
* or protocol used by the chain, e.g. by verifying the PoW on the block.
*
* Supported consensus types and algorithms (taken from the `Common` instance):
* - 'pow' with 'ethash' algorithm (validates the proof-of-work)
* - 'poa' with 'clique' algorithm (verifies the block signatures)
* Default: `true`.
*/
validateConsensus?: boolean;
/**
* This flag indicates if protocol-given consistency checks on
* block headers and included uncles and transactions should be performed,
* see Block#validate for details.
*
*/
validateBlocks?: boolean;
/**
* The blockchain only initializes successfully if it has a genesis block. If
* there is no block available in the DB and a `genesisBlock` is provided,
* then the provided `genesisBlock` will be used as genesis. If no block is
* present in the DB and no block is provided, then the genesis block as
* provided from the `common` will be used.
*/
genesisBlock?: Block_3;
/**
* If you are using a custom chain {@link Common}, pass the genesis state.
*
* Pattern 1 (with genesis state see {@link GenesisState} for format):
*
* ```javascript
* {
* '0x0...01': '0x100', // For EoA
* }
* ```
*
* Pattern 2 (with complex genesis state, containing contract accounts and storage).
* Note that in {@link AccountState} there are two
* accepted types. This allows to easily insert accounts in the genesis state:
*
* A complex genesis state with Contract and EoA states would have the following format:
*
* ```javascript
* {
* '0x0...01': '0x100', // For EoA
* '0x0...02': ['0x1', '0xRUNTIME_BYTECODE', [[storageKey1, storageValue1], [storageKey2, storageValue2]]] // For contracts
* }
* ```
*/
genesisState?: GenesisState;
/**
* Optional custom consensus that implements the {@link Consensus} class
*/
consensus?: Consensus;
}
declare type BlockchainTypedEvents = {
block: Block;
blockLogs: BlockLogs;
pendingTransaction: TypedTransaction;
"ganache:vm:tx:step": VmStepEvent;
"ganache:vm:tx:before": VmBeforeTransactionEvent;
"ganache:vm:tx:after": VmAfterTransactionEvent;
"ganache:vm:tx:console.log": VmConsoleLogEvent;
ready: undefined;
stop: undefined;
};
/**
* A block's data.
*/
declare interface BlockData {
/**
* Header data for the block
*/
header?: HeaderData;
transactions?: Array;
uncleHeaders?: Array;
}
declare type BlockHashFilterArgs = BaseFilterArgs & {
blockHash?: string;
};
declare type BlockHeader = {
parentHash: Data;
sha3Uncles: Data;
miner: Data;
stateRoot: Data;
transactionsRoot: Data;
receiptsRoot: Data;
logsBloom: Data;
difficulty: Quantity;
totalDifficulty: Quantity;
number: Quantity;
gasLimit: Quantity;
gasUsed: Quantity;
timestamp: Quantity;
extraData: Data;
mixHash: Data;
nonce: Data;
baseFeePerGas?: Quantity;
};
/**
* An object that represents the block header.
*/
declare class BlockHeader_2 {
readonly parentHash: Buffer;
readonly uncleHash: Buffer;
readonly coinbase: Address_2;
readonly stateRoot: Buffer;
readonly transactionsTrie: Buffer;
readonly receiptTrie: Buffer;
readonly logsBloom: Buffer;
readonly difficulty: bigint;
readonly number: bigint;
readonly gasLimit: bigint;
readonly gasUsed: bigint;
readonly timestamp: bigint;
readonly extraData: Buffer;
readonly mixHash: Buffer;
readonly nonce: Buffer;
readonly baseFeePerGas?: bigint;
readonly _common: Common;
private cache;
/**
* EIP-4399: After merge to PoS, `mixHash` supplanted as `prevRandao`
*/
get prevRandao(): Buffer;
/**
* Static constructor to create a block header from a header data dictionary
*
* @param headerData
* @param opts
*/
static fromHeaderData(headerData?: HeaderData, opts?: BlockOptions): BlockHeader_2;
/**
* Static constructor to create a block header from a RLP-serialized header
*
* @param serializedHeaderData
* @param opts
*/
static fromRLPSerializedHeader(serializedHeaderData: Buffer, opts?: BlockOptions): BlockHeader_2;
/**
* Static constructor to create a block header from an array of Buffer values
*
* @param values
* @param opts
*/
static fromValuesArray(values: BlockHeaderBuffer, opts?: BlockOptions): BlockHeader_2;
/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* @deprecated Use the public static factory methods to assist in creating a Header object from
* varying data types. For a default empty header, use {@link BlockHeader.fromHeaderData}.
*
*/
constructor(headerData: HeaderData, options?: BlockOptions);
/**
* Validates correct buffer lengths, throws if invalid.
*/
_genericFormatValidation(): void;
/**
* Checks static parameters related to consensus algorithm
* @throws if any check fails
*/
_consensusFormatValidation(): void;
/**
* Validates if the block gasLimit remains in the boundaries set by the protocol.
* Throws if out of bounds.
*
* @param parentBlockHeader - the header from the parent `Block` of this header
*/
validateGasLimit(parentBlockHeader: BlockHeader_2): void;
/**
* Calculates the base fee for a potential next block
*/
calcNextBaseFee(): bigint;
/**
* Returns a Buffer Array of the raw Buffers in this header, in order.
*/
raw(): BlockHeaderBuffer;
/**
* Returns the hash of the block header.
*/
hash(): Buffer;
/**
* Checks if the block header is a genesis header.
*/
isGenesis(): boolean;
private _requireClique;
/**
* Returns the canonical difficulty for this block.
*
* @param parentBlockHeader - the header from the parent `Block` of this header
*/
ethashCanonicalDifficulty(parentBlockHeader: BlockHeader_2): bigint;
/**
* PoA clique signature hash without the seal.
*/
cliqueSigHash(): Buffer;
/**
* Checks if the block header is an epoch transition
* header (only clique PoA, throws otherwise)
*/
cliqueIsEpochTransition(): boolean;
/**
* Returns extra vanity data
* (only clique PoA, throws otherwise)
*/
cliqueExtraVanity(): Buffer;
/**
* Returns extra seal data
* (only clique PoA, throws otherwise)
*/
cliqueExtraSeal(): Buffer;
/**
* Seal block with the provided signer.
* Returns the final extraData field to be assigned to `this.extraData`.
* @hidden
*/
private cliqueSealBlock;
/**
* Returns a list of signers
* (only clique PoA, throws otherwise)
*
* This function throws if not called on an epoch
* transition block and should therefore be used
* in conjunction with {@link BlockHeader.cliqueIsEpochTransition}
*/
cliqueEpochTransitionSigners(): Address_2[];
/**
* Verifies the signature of the block (last 65 bytes of extraData field)
* (only clique PoA, throws otherwise)
*
* Method throws if signature is invalid
*/
cliqueVerifySignature(signerList: Address_2[]): boolean;
/**
* Returns the signer address
*/
cliqueSigner(): Address_2;
/**
* Returns the rlp encoding of the block header.
*/
serialize(): Buffer;
/**
* Returns the block header in JSON format.
*/
toJSON(): JsonHeader;
/**
* Validates extra data is DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)
*/
private _validateDAOExtraData;
/**
* Return a compact error string representation of the object
*/
errorStr(): string;
/**
* Helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string): string;
}
declare class BlockHeader_3 extends SerializableObject implements DeserializedObject {
get config(): Definitions;
constructor(options?: Partial> | Partial>);
miner: Address_3;
ticket: Ticket;
electionProof: ElectionProof;
beaconEntries: Array;
winPoStProof: Array;
parents: Array;
parentWeight: bigint;
height: number;
parentStateRoot: RootCID;
parentMessageReceipts: RootCID;
messages: RootCID;
blsAggregate: Signature;
/**
* Timestamp in seconds. Reference implementation: https://git.io/Jt3HJ.
*/
timestamp: number;
blockSignature: Signature;
forkSignaling: 0 | 1;
parentBaseFee: bigint;
}
declare type BlockHeaderBuffer = Buffer[];
declare interface BlockHeaderConfig {
properties: {
miner: {
type: Address_3;
serializedType: SerializedAddress;
serializedName: "Miner";
};
ticket: {
type: Ticket;
serializedType: SerializedTicket;
serializedName: "Ticket";
};
electionProof: {
type: ElectionProof;
serializedType: SerializedElectionProof;
serializedName: "ElectionProof";
};
beaconEntries: {
type: Array;
serializedType: Array;
serializedName: "BeaconEntries";
};
winPoStProof: {
type: Array;
serializedType: Array;
serializedName: "WinPoStProof";
};
parents: {
type: Array;
serializedType: Array;
serializedName: "Parents";
};
parentWeight: {
type: bigint;
serializedType: string;
serializedName: "ParentWeight";
};
height: {
type: number;
serializedType: number;
serializedName: "Height";
};
parentStateRoot: {
type: RootCID;
serializedType: SerializedRootCID;
serializedName: "ParentStateRoot";
};
parentMessageReceipts: {
type: RootCID;
serializedType: SerializedRootCID;
serializedName: "ParentMessageReceipts";
};
messages: {
type: RootCID;
serializedType: SerializedRootCID;
serializedName: "Messages";
};
blsAggregate: {
type: Signature;
serializedType: SerializedSignature;
serializedName: "BLSAggregate";
};
timestamp: {
type: number;
serializedType: number;
serializedName: "Timestamp";
};
blockSignature: {
type: Signature;
serializedType: SerializedSignature;
serializedName: "BlockSig";
};
forkSignaling: {
type: 0 | 1;
serializedType: 0 | 1;
serializedName: "ForkSignaling";
};
parentBaseFee: {
type: bigint;
serializedType: string;
serializedName: "ParentBaseFee";
};
};
}
declare class BlockHeaderManager extends Manager_2 {
static initialize(base: LevelUp): Promise;
constructor(base: LevelUp);
/**
* Writes the blockHeader object to the underlying database.
* @param blockHeader -
*/
putBlockHeader(blockHeader: BlockHeader_3): Promise;
}
declare type BlockLog = [
removed: Buffer,
transactionIndex: Buffer,
transactionHash: Buffer,
address: TransactionLog[0],
topics: TransactionLog[1],
data: TransactionLog[2]
];
declare class BlockLogManager extends Manager {
#private;
constructor(base: GanacheLevelUp, blockchain: Blockchain);
get(key: string | Buffer): Promise;
getLogs(filter: FilterArgs): Promise;
}
declare class BlockLogs {
[_raw]: [blockHash: Buffer, blockLog: BlockLog[]];
constructor(data: Buffer);
/**
*
* @param blockHash - Creates an BlogLogs entity with an empty internal logs
* array.
*/
static create(blockHash: Data): BlockLogs;
/**
* rlpEncode's the blockHash and logs array for db storage
*/
serialize(): Buffer;
/**
* Appends the data to the internal logs array
* @param transactionIndex -
* @param transactionHash -
* @param log -
*/
append(transactionIndex: Quantity, transactionHash: Data, log: TransactionLog): void;
/**
* Returns the number of logs in the internal logs array.
*/
get length(): number;
blockNumber: Quantity;
static fromJSON(json: any[] | null): BlockLogs;
toJSON(): {
[Symbol.iterator](): Generator;
};
[_logs](): {
toJSON(): {
[Symbol.iterator](): Generator;
};
[Symbol.iterator](): Generator<{
address: Buffer;
topics: Buffer[];
toJSON: () => Log_2;
}, void, unknown>;
};
/**
*
* @param log -
* @param logIndex - The index this log appears in the block
* @param blockHash - The hash of the block
* @param blockNumber - The block number
*/
protected static logToJSON(log: BlockLog, logIndex: Quantity, blockHash: Data, blockNumber: Quantity): Log_2;
/**
* Note: you must set `this.blockNumber: Quantity` first!
*
* Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic
* filters:
* ▸ [] "anything"
* ▸ [A] "A in first position (and anything after)"
* ▸ [null, B] "anything in first position AND B in second position (and anything after)"
* ▸ [A, B] "A" in first position AND B in second position (and anything after)"
* ▸ [[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position (and anything after)"
* @param expectedAddresses -
* @param expectedTopics -
* @returns JSON representation of the filtered logs
*/
filter(expectedAddresses: Buffer[], expectedTopics: (string | string[])[]): Generator;
}
declare class BlockManager extends Manager {
#private;
/**
* The earliest block
*/
earliest: Block;
/**
* The latest block
*/
latest: Block;
/**
* The next block
*/
pending: Block;
static initialize(blockchain: Blockchain, common: Common, blockIndexes: GanacheLevelUp, base: GanacheLevelUp): Promise;
constructor(blockchain: Blockchain, common: Common, blockIndexes: GanacheLevelUp, base: GanacheLevelUp);
static rawFromJSON(json: any, common: Common): Buffer;
fromFallback: (tagOrBlockNumber: string | Quantity) => Promise;
getBlockByTag(tag: Tag): Block;
getEffectiveNumber(tagOrBlockNumber?: QUANTITY | Buffer | Tag): Quantity;
getNumberFromHash(hash: string | Buffer | Tag): Promise;
getByHash(hash: string | Buffer | Tag): Promise;
getRawByBlockNumber(blockNumber: Quantity): Promise;
get(tagOrBlockNumber: QUANTITY | Buffer | Tag): Promise;
/**
* Writes the block object to the underlying database.
* @param block -
*/
putBlock(number: Buffer, hash: Data, serialized: Buffer): Promise;
/**
* Updates the "latest" index to point to the given number.
* @param number the block number of the latest block
*/
updateLatestIndex(number: Buffer): Promise;
getEarliest(): Promise;
/**
* Updates the this.latest and this.earliest properties with data
* from the database.
*/
updateTaggedBlocks(): Promise;
}
declare class BlockMessages extends SerializableObject implements DeserializedObject {
get config(): Definitions;
constructor(options?: Partial> | Partial>);
/**
* The messages in the block that were signed with BLS.
* In Ganache, this should always contain all of the
* messages due to always signing new blocks with BLS.
*/
blsMessages: Array;
/**
* The messages in the block that were signed with Secpk.
* In Ganache, this should always be empty due to always
* signing new blocks with BLS.
*/
secpkMessages: Array;
cids: Array;
initializeCids(): void;
static fromSignedMessages(signedMessages: Array): BlockMessages;
}
declare type BlockMessagesConfig = {
properties: {
blsMessages: {
type: Array;
serializedType: Array;
serializedName: "BlsMessages";
};
secpkMessages: {
type: Array;
serializedType: Array;
serializedName: "SecpkMessages";
};
cids: {
type: Array;
serializedType: Array;
serializedName: "Cids";
};
};
};
declare class BlockMessagesManager extends Manager_2 {
#private;
static initialize(base: LevelUp, signedMessageManager: SignedMessageManager): Promise;
constructor(base: LevelUp, signedMessageManager: SignedMessageManager);
putBlockMessages(blockCID: CID, messages: BlockMessages): Promise;
getBlockMessages(blockCID: CID): Promise;
}
/**
* An object to set to which blockchain the blocks and their headers belong. This could be specified
* using a {@link Common} object, or `chain` and `hardfork`. Defaults to mainnet without specifying a
* hardfork.
*/
declare interface BlockOptions {
/**
* A {@link Common} object defining the chain and the hardfork a block/block header belongs to.
*
* Object will be internally copied so that tx behavior don't incidentally
* change on future HF changes.
*
* Default: {@link Common} object set to `mainnet` and the HF currently defined as the default
* hardfork in the {@link Common} class.
*
* Current default hardfork: `merge`
*/
common?: Common;
/**
* Determine the HF by the block number
*
* Default: `false` (HF is set to whatever default HF is set by the {@link Common} instance)
*/
hardforkByBlockNumber?: boolean;
/**
* Determine the HF by total difficulty (Merge HF)
*
* This option is a superset of `hardforkByBlockNumber` (so only use one of both options)
* and determines the HF by both the block number and the TD.
*
* Since the TTD is only a threshold the block number will in doubt take precedence (imagine
* e.g. both Merge and Shanghai HF blocks set and the block number from the block provided
* pointing to a Shanghai block: this will lead to set the HF as Shanghai and not the Merge).
*/
hardforkByTTD?: BigIntLike;
/**
* If a preceding {@link BlockHeader} (usually the parent header) is given the preceding
* header will be used to calculate the difficulty for this block and the calculated
* difficulty takes precedence over a provided static `difficulty` value.
*
* Note that this option has no effect on networks other than PoW/Ethash networks
* (respectively also deactivates on the Merge HF switching to PoS/Casper).
*/
calcDifficultyFromHeader?: BlockHeader_2;
/**
* A block object by default gets frozen along initialization. This gives you
* strong additional security guarantees on the consistency of the block parameters.
* It also enables block hash caching when the `hash()` method is called multiple times.
*
* If you need to deactivate the block freeze - e.g. because you want to subclass block and
* add aditional properties - it is strongly encouraged that you do the freeze yourself
* within your code instead.
*
* Default: true
*/
freeze?: boolean;
/**
* Provide a clique signer's privateKey to seal this block.
* Will throw if provided on a non-PoA chain.
*/
cliqueSigner?: Buffer;
/**
* Skip consensus format validation checks on header if set. Defaults to false.
*/
skipConsensusFormatValidation?: boolean;
}
declare class Bloom {
bitvector: Buffer;
/**
* Represents a Bloom filter.
*/
constructor(bitvector?: Buffer);
/**
* Adds an element to a bit vector of a 64 byte bloom filter.
* @param e - The element to add
*/
add(e: Buffer): void;
/**
* Checks if an element is in the bloom.
* @param e - The element to check
*/
check(e: Buffer): boolean;
/**
* Checks if multiple topics are in a bloom.
* @returns `true` if every topic is in the bloom
*/
multiCheck(topics: Buffer[]): boolean;
/**
* Bitwise or blooms together.
*/
or(bloom: Bloom): void;
}
declare interface BootstrapNodeConfig {
ip: string;
port: number | string;
network?: string;
chainId?: number;
id: string;
location: string;
comment: string;
}
declare class BranchNode {
_branches: (EmbeddedNode | null)[];
_value: Buffer | null;
constructor();
static fromArray(arr: Buffer[]): BranchNode;
value(v?: Buffer | null): Buffer | null;
setBranch(i: number, v: EmbeddedNode | null): void;
raw(): (EmbeddedNode | null)[];
serialize(): Buffer;
getBranch(i: number): EmbeddedNode | null;
getChildren(): [number, EmbeddedNode][];
}
declare type BufferLike = Buffer | Uint8Array | number[] | number | bigint | TransformableToBuffer | PrefixedHexString;
/**
* Options for building a block.
*/
declare interface BuildBlockOpts {
/**
* The parent block
*/
parentBlock: Block_3;
/**
* The block header data to use.
* Defaults used for any values not provided.
*/
headerData?: HeaderData;
/**
* The block and builder options to use.
*/
blockOpts?: BuilderOpts;
}
/**
* Options for the block builder.
*/
declare interface BuilderOpts extends BlockOptions {
/**
* Whether to put the block into the vm's blockchain after building it.
* This is useful for completing a full cycle when building a block so
* the only next step is to build again, however it may not be desired
* if the block is being emulated or may be discarded as to not affect
* the underlying blockchain.
*
* Default: true
*/
putBlockIntoBlockchain?: boolean;
}
/**
* Simple LRU Cache that allows for keys of type Buffer
* @hidden
*/
declare class Cache {
_cache: LRUCache;
constructor(opts: LRUCache.Options);
set(key: string | Buffer, value: V): void;
get(key: string | Buffer): V | undefined;
del(key: string | Buffer): void;
}
declare type CacheMap = {
[key: string]: Cache;
};
/**
* Compute the 'intrinsic gas' for a message with the given data.
* @param data - The transaction's data
* @param hasToAddress - boolean,
* @param common - The Common use to determine gas costs
* @returns The absolute minimum amount of gas this transaction will consume,
* or `-1` if the data in invalid (gas consumption would exceed `MAX_UINT64`
* (`(2n ** 64n) - 1n`).
*/
declare const calculateIntrinsicGas: (data: Data, hasToAddress: boolean, common: Common) => bigint;
declare interface Callback {
(err?: Error, response?: JsonRpcResponse | JsonRpcError): void;
}
declare type Callback_2 = (err: Error | null) => void;
declare class CallError extends CodedError {
code: JsonRpcErrorCode;
data: string;
constructor(result: EVMResult);
}
declare type CallOverride = Partial<{
code: string;
nonce: string;
balance: string;
state: {
[slot: string]: string;
};
stateDiff: never;
}> | Partial<{
code: string;
nonce: string;
balance: string;
state: never;
stateDiff: {
[slot: string]: string;
};
}>;
declare type CallOverrides = {
[address: string]: CallOverride;
};
declare type CallTransaction = Omit & {
from?: string;
};
declare type Capability = 2718 | 2930 | 1559;
/**
* Can be used in conjunction with {@link Transaction.supports}
* to query on tx capabilities
*/
declare enum Capability_2 {
/**
* Tx supports EIP-155 replay protection
* See: [155](https://eips.ethereum.org/EIPS/eip-155) Replay Attack Protection EIP
*/
EIP155ReplayProtection = 155,
/**
* Tx supports EIP-1559 gas fee market mechanism
* See: [1559](https://eips.ethereum.org/EIPS/eip-1559) Fee Market EIP
*/
EIP1559FeeMarket = 1559,
/**
* Tx is a typed transaction as defined in EIP-2718
* See: [2718](https://eips.ethereum.org/EIPS/eip-2718) Transaction Type EIP
*/
EIP2718TypedTransaction = 2718,
/**
* Tx supports access list generation as defined in EIP-2930
* See: [2930](https://eips.ethereum.org/EIPS/eip-2930) Access Lists EIP
*/
EIP2930AccessLists = 2930
}
/**
* How many transactions should be in the block.
*/
declare enum Capacity {
/**
* Keep mining transactions until there are no more transactions that can fit
* in the block, or there are no transactions left to mine.
*/
FillBlock = -1,
/**
* Mine an empty block, even if there are executable transactions available to
* mine.
*/
Empty = 0,
/**
* Mine a block with a single transaction, or empty if there are no executable
* transactions available to mine.
*/
Single = 1
}
declare type CasperConfig = {};
declare enum Chain {
Mainnet = 1,
Ropsten = 3,
Rinkeby = 4,
Goerli = 5,
Sepolia = 11155111
}
declare type ChainConfig = {
options: {
/**
* Allows unlimited contract sizes while debugging. By setting this to
* `true`, the check within the EVM for a contract size limit of 24KB (see
* [EIP-170](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md))
* is bypassed. Setting this to `true` will cause ganache to behave
* differently than production environments. You should only set this to
* `true` during local debugging.
*
* @defaultValue false
*/
readonly allowUnlimitedContractSize: {
type: boolean;
hasDefault: true;
legacy: {
/**
* @deprecated Use chain.allowUnlimitedContractSize instead
*/
allowUnlimitedContractSize: boolean;
};
};
/**
* When set to `false` only one request will be processed at a time.
*
* @defaultValue true
*/
readonly asyncRequestProcessing: {
type: boolean;
hasDefault: true;
legacy: {
/**
* @deprecated Use chain.asyncRequestProcessing instead
*/
asyncRequestProcessing: boolean;
};
};
/**
* The currently configured chain id, a value used in replay-protected
* transaction signing as introduced by
* [EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md).
*
* @defaultValue 1337
*/
readonly chainId: {
type: number;
hasDefault: true;
legacy: {
/**
* @deprecated Use chain.chainId instead
*/
chainId: number;
};
};
/**
* The id of the network returned by the RPC method `net_version`.
*
* Defaults to the current timestamp, via JavaScript's `Date.now()` (the
* number of milliseconds since the UNIX epoch).
*
* @defaultValue Date.now()
*/
readonly networkId: {
type: number;
hasDefault: true;
legacy: {
/**
* @deprecated Use chain.networkId instead
*/
network_id: number;
};
};
/**
* Date that the first block should start. Use this feature, along with the
* `evm_increaseTime` RPC, to test time-dependent code.
*/
readonly time: {
type: Date | null;
rawType: Date | string | number;
legacy: {
/**
* @deprecated Use chain.time instead
*/
time: Date | string;
};
cliType: string;
};
/**
* Set the hardfork rules for the EVM.
* @defaultValue "merge"
*/
readonly hardfork: {
type: Hardfork;
hasDefault: true;
legacy: {
/**
* @deprecated Use chain.hardfork instead
*/
hardfork: Hardfork;
};
};
/**
* Whether to report runtime errors from EVM code as RPC errors.
*
* @defaultValue false
*/
readonly vmErrorsOnRPCResponse: {
type: boolean;
hasDefault: true;
legacy: {
/**
* @deprecated Use chain.vmErrorsOnRPCResponse instead
*/
vmErrorsOnRPCResponse: boolean;
};
};
};
};
declare interface ChainConfig_2 {
name: string;
chainId: number | bigint;
networkId: number | bigint;
defaultHardfork: string;
comment: string;
url: string;
genesis: GenesisBlockConfig;
hardforks: HardforkConfig[];
bootstrapNodes: BootstrapNodeConfig[];
dnsNetworks?: string[];
consensus: {
type: ConsensusType | string;
algorithm: ConsensusAlgorithm | string;
clique?: CliqueConfig;
ethash?: EthashConfig;
casper?: CasperConfig;
};
}
declare type ChainConfig_3 = {
options: {
/**
* The IPFS simulator host name/address to listen on.
*
* @defaultValue "127.0.0.1"
*/
readonly ipfsHost: {
type: string;
hasDefault: true;
};
/**
* The IPFS simulator port.
*
* @defaultValue 5001
*/
readonly ipfsPort: {
type: number;
hasDefault: true;
};
/**
* When set to `false` only one request will be processed at a time.
*
* @defaultValue true
*/
readonly asyncRequestProcessing: {
type: boolean;
hasDefault: true;
};
};
};
declare interface ChainName {
[chainId: string]: string;
}
declare interface ChainsConfig {
[key: string]: ChainConfig_2 | ChainName;
}
declare const ChannelClosed: "xrpc.ch.close";
declare class ChannelID extends SerializableObject implements DeserializedObject {
get config(): Definitions;
constructor(options?: Partial> | Partial>);
initiator: string;
responder: string;
id: number;
}
declare type ChannelIDConfig = {
properties: {
initiator: {
type: string;
serializedType: string;
serializedName: "Initiator";
};
responder: {
type: string;
serializedType: string;
serializedName: "Responder";
};
id: {
type: number;
serializedType: number;
serializedName: "ID";
};
};
};
declare type Checkpoint = {
keyValueMap: Map;
root: Buffer;
};
/**
* DB is a thin wrapper around the underlying levelup db,
* which validates inputs and sets encoding type.
*/
declare class CheckpointDB implements DB {
checkpoints: Checkpoint[];
db: DB;
/**
* Initialize a DB instance.
*/
constructor(db: DB);
/**
* Flush the checkpoints and use the given checkpoints instead.
* @param {Checkpoint[]} checkpoints
*/
setCheckpoints(checkpoints: Checkpoint[]): void;
/**
* Is the DB during a checkpoint phase?
*/
hasCheckpoints(): boolean;
/**
* Adds a new checkpoint to the stack
* @param root
*/
checkpoint(root: Buffer): void;
/**
* Commits the latest checkpoint
*/
commit(): Promise;
/**
* Reverts the latest checkpoint
*/
revert(): Promise;
/**
* @inheritDoc
*/
get(key: Buffer): Promise;
/**
* @inheritDoc
*/
put(key: Buffer, val: Buffer): Promise;
/**
* @inheritDoc
*/
del(key: Buffer): Promise;
/**
* @inheritDoc
*/
batch(opStack: BatchDBOp[]): Promise;
/**
* @inheritDoc
*/
copy(): CheckpointDB;
}
declare class CID extends SerializableLiteral {
get config(): {};
static isValid(value: string): boolean;
static nullCID(): CID;
}
declare interface CIDConfig {
type: string;
}
declare type CliqueConfig = {
period: number;
epoch: number;
};
declare type CliTypes = PrimitiveCliTypes | PrimitiveCliTypes[] | string[] | number[] | boolean[];
declare class CodedError extends Error {
code: number;
constructor(message: string, code: number);
static from(error: Error, code: JsonRpcErrorCode): CodedError;
static nonEnumerableProperty(value: any): {
value: any;
writable: boolean;
configurable: boolean;
};
static captureStackTraceExtended(message: string): void;
static createRevertReason(returnValue: Buffer): string;
}
declare type Combine, T extends "rawType" | "type"> = {
[N in keyof GRP]: GRP[N] extends OptionName ? {
[Key in keyof (ExclusiveGroupOptionalUnionByName & UnconstrainedOptionsByType & O)]: Key extends keyof ExclusiveGroupOptionalUnionByName ? ExclusiveGroupOptionalUnionByName[Key] : Key extends keyof UnconstrainedOptionsByType ? UnconstrainedOptionsByType[Key] : Key extends keyof O ? O[Key] : never;
} : never;
} extends {
[n: number]: infer I;
} ? I : never;
/**
* Common class to access chain and hardfork parameters and to provide
* a unified and shared view on the network and hardfork state.
*
* Use the {@link Common.custom} static constructor for creating simple
* custom chain {@link Common} objects (more complete custom chain setups
* can be created via the main constructor and the {@link CommonOpts.customChains} parameter).
*/
declare class Common extends EventEmitter {
readonly DEFAULT_HARDFORK: string | Hardfork_2;
private _chainParams;
private _hardfork;
private _eips;
private _customChains;
private HARDFORK_CHANGES;
/**
* Creates a {@link Common} object for a custom chain, based on a standard one.
*
* It uses all the {@link Chain} parameters from the {@link baseChain} option except the ones overridden
* in a provided {@link chainParamsOrName} dictionary. Some usage example:
*
* ```javascript
* Common.custom({chainId: 123})
* ```
*
* There are also selected supported custom chains which can be initialized by using one of the
* {@link CustomChains} for {@link chainParamsOrName}, e.g.:
*
* ```javascript
* Common.custom(CustomChains.MaticMumbai)
* ```
*
* Note that these supported custom chains only provide some base parameters (usually the chain and
* network ID and a name) and can only be used for selected use cases (e.g. sending a tx with
* the `@ethereumjs/tx` library to a Layer-2 chain).
*
* @param chainParamsOrName Custom parameter dict (`name` will default to `custom-chain`) or string with name of a supported custom chain
* @param opts Custom chain options to set the {@link CustomCommonOpts.baseChain}, selected {@link CustomCommonOpts.hardfork} and others
*/
static custom(chainParamsOrName: Partial | CustomChain, opts?: CustomCommonOpts): Common;
/**
* Static method to load and set common from a geth genesis json
* @param genesisJson json of geth configuration
* @param { chain, genesisHash, hardfork } to futher configure the common instance
* @returns Common
*/
static fromGethGenesis(genesisJson: any, { chain, genesisHash, hardfork }: GethConfigOpts): Common;
/**
* Static method to determine if a {@link chainId} is supported as a standard chain
* @param chainId bigint id (`1`) of a standard chain
* @returns boolean
*/
static isSupportedChainId(chainId: bigint): boolean;
private static _getChainParams;
constructor(opts: CommonOpts);
/**
* Sets the chain
* @param chain String ('mainnet') or Number (1) chain representation.
* Or, a Dictionary of chain parameters for a private network.
* @returns The dictionary with parameters set as chain
*/
setChain(chain: string | number | Chain | bigint | object): ChainConfig_2;
/**
* Sets the hardfork to get params for
* @param hardfork String identifier (e.g. 'byzantium') or {@link Hardfork} enum
*/
setHardfork(hardfork: string | Hardfork_2): void;
/**
* Returns the hardfork based on the block number or an optional
* total difficulty (Merge HF) provided.
*
* An optional TD takes precedence in case the corresponding HF block
* is set to `null` or otherwise needs to match (if not an error
* will be thrown).
*
* @param blockNumber
* @param td : total difficulty of the parent block (for block hf) OR of the the chain latest (for chain hf)
* @returns The name of the HF
*/
getHardforkByBlockNumber(blockNumber: BigIntLike, td?: BigIntLike): string;
/**
* Sets a new hardfork based on the block number or an optional
* total difficulty (Merge HF) provided.
*
* An optional TD takes precedence in case the corresponding HF block
* is set to `null` or otherwise needs to match (if not an error
* will be thrown).
*
* @param blockNumber
* @param td
* @returns The name of the HF set
*/
setHardforkByBlockNumber(blockNumber: BigIntLike, td?: BigIntLike): string;
/**
* Internal helper function, returns the params for the given hardfork for the chain set
* @param hardfork Hardfork name
* @returns Dictionary with hardfork params or null if hardfork not on chain
*/
_getHardfork(hardfork: string | Hardfork_2): HardforkConfig | null;
/**
* Sets the active EIPs
* @param eips
*/
setEIPs(eips?: number[]): void;
/**
* Returns a parameter for the current chain setup
*
* If the parameter is present in an EIP, the EIP always takes precendence.
* Otherwise the parameter if taken from the latest applied HF with
* a change on the respective parameter.
*
* @param topic Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow')
* @param name Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
* @returns The value requested or `BigInt(0)` if not found
*/
param(topic: string, name: string): bigint;
/**
* Returns the parameter corresponding to a hardfork
* @param topic Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow')
* @param name Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
* @param hardfork Hardfork name
* @returns The value requested or `BigInt(0)` if not found
*/
paramByHardfork(topic: string, name: string, hardfork: string | Hardfork_2): bigint;
/**
* Returns a parameter corresponding to an EIP
* @param topic Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow')
* @param name Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
* @param eip Number of the EIP
* @returns The value requested or `undefined` if not found
*/
paramByEIP(topic: string, name: string, eip: number): bigint | undefined;
/**
* Returns a parameter for the hardfork active on block number or
* optional provided total difficulty (Merge HF)
* @param topic Parameter topic
* @param name Parameter name
* @param blockNumber Block number
* @param td Total difficulty
* * @returns The value requested or `BigInt(0)` if not found
*/
paramByBlock(topic: string, name: string, blockNumber: BigIntLike, td?: BigIntLike): bigint;
/**
* Checks if an EIP is activated by either being included in the EIPs
* manually passed in with the {@link CommonOpts.eips} or in a
* hardfork currently being active
*
* Note: this method only works for EIPs being supported
* by the {@link CommonOpts.eips} constructor option
* @param eip
*/
isActivatedEIP(eip: number): boolean;
/**
* Checks if set or provided hardfork is active on block number
* @param hardfork Hardfork name or null (for HF set)
* @param blockNumber
* @returns True if HF is active on block number
*/
hardforkIsActiveOnBlock(hardfork: string | Hardfork_2 | null, blockNumber: BigIntLike): boolean;
/**
* Alias to hardforkIsActiveOnBlock when hardfork is set
* @param blockNumber
* @returns True if HF is active on block number
*/
activeOnBlock(blockNumber: BigIntLike): boolean;
/**
* Sequence based check if given or set HF1 is greater than or equal HF2
* @param hardfork1 Hardfork name or null (if set)
* @param hardfork2 Hardfork name
* @param opts Hardfork options
* @returns True if HF1 gte HF2
*/
hardforkGteHardfork(hardfork1: string | Hardfork_2 | null, hardfork2: string | Hardfork_2): boolean;
/**
* Alias to hardforkGteHardfork when hardfork is set
* @param hardfork Hardfork name
* @returns True if hardfork set is greater than hardfork provided
*/
gteHardfork(hardfork: string | Hardfork_2): boolean;
/**
* Returns the hardfork change block for hardfork provided or set
* @param hardfork Hardfork name, optional if HF set
* @returns Block number or null if unscheduled
*/
hardforkBlock(hardfork?: string | Hardfork_2): bigint | null;
/**
* Returns the hardfork change block for eip
* @param eip EIP number
* @returns Block number or null if unscheduled
*/
eipBlock(eip: number): bigint | null;
/**
* Returns the hardfork change total difficulty (Merge HF) for hardfork provided or set
* @param hardfork Hardfork name, optional if HF set
* @returns Total difficulty or null if no set
*/
hardforkTTD(hardfork?: string | Hardfork_2): bigint | null;
/**
* True if block number provided is the hardfork (given or set) change block
* @param blockNumber Number of the block to check
* @param hardfork Hardfork name, optional if HF set
* @returns True if blockNumber is HF block
*/
isHardforkBlock(blockNumber: BigIntLike, hardfork?: string | Hardfork_2): boolean;
/**
* Returns the change block for the next hardfork after the hardfork provided or set
* @param hardfork Hardfork name, optional if HF set
* @returns Block number or null if not available
*/
nextHardforkBlock(hardfork?: string | Hardfork_2): bigint | null;
/**
* True if block number provided is the hardfork change block following the hardfork given or set
* @param blockNumber Number of the block to check
* @param hardfork Hardfork name, optional if HF set
* @returns True if blockNumber is HF block
*/
isNextHardforkBlock(blockNumber: BigIntLike, hardfork?: string | Hardfork_2): boolean;
/**
* Internal helper function to calculate a fork hash
* @param hardfork Hardfork name
* @param genesisHash Genesis block hash of the chain
* @returns Fork hash as hex string
*/
_calcForkHash(hardfork: string | Hardfork_2, genesisHash: Buffer): string;
/**
* Returns an eth/64 compliant fork hash (EIP-2124)
* @param hardfork Hardfork name, optional if HF set
* @param genesisHash Genesis block hash of the chain, optional if already defined and not needed to be calculated
*/
forkHash(hardfork?: string | Hardfork_2, genesisHash?: Buffer): string;
/**
*
* @param forkHash Fork hash as a hex string
* @returns Array with hardfork data (name, block, forkHash)
*/
hardforkForForkHash(forkHash: string): HardforkConfig | null;
/**
* Sets any missing forkHashes on the passed-in {@link Common} instance
* @param common The {@link Common} to set the forkHashes for
* @param genesisHash The genesis block hash
*/
setForkHashes(genesisHash: Buffer): void;
/**
* Returns the Genesis parameters of the current chain
* @returns Genesis dictionary
*/
genesis(): GenesisBlockConfig;
/**
* Returns the hardforks for current chain
* @returns {Array} Array with arrays of hardforks
*/
hardforks(): HardforkConfig[];
/**
* Returns bootstrap nodes for the current chain
* @returns {Dictionary} Dict with bootstrap nodes
*/
bootstrapNodes(): BootstrapNodeConfig[];
/**
* Returns DNS networks for the current chain
* @returns {String[]} Array of DNS ENR urls
*/
dnsNetworks(): string[];
/**
* Returns the hardfork set
* @returns Hardfork name
*/
hardfork(): string | Hardfork_2;
/**
* Returns the Id of current chain
* @returns chain Id
*/
chainId(): bigint;
/**
* Returns the name of current chain
* @returns chain name (lower case)
*/
chainName(): string;
/**
* Returns the Id of current network
* @returns network Id
*/
networkId(): bigint;
/**
* Returns the active EIPs
* @returns List of EIPs
*/
eips(): number[];
/**
* Returns the consensus type of the network
* Possible values: "pow"|"poa"|"pos"
*
* Note: This value can update along a Hardfork.
*/
consensusType(): string | ConsensusType;
/**
* Returns the concrete consensus implementation
* algorithm or protocol for the network
* e.g. "ethash" for "pow" consensus type,
* "clique" for "poa" consensus type or
* "casper" for "pos" consensus type.
*
* Note: This value can update along a Hardfork.
*/
consensusAlgorithm(): string | ConsensusAlgorithm;
/**
* Returns a dictionary with consensus configuration
* parameters based on the consensus algorithm
*
* Expected returns (parameters must be present in
* the respective chain json files):
*
* ethash: -
* clique: period, epoch
* aura: -
* casper: -
*
* Note: This value can update along a Hardfork.
*/
consensusConfig(): {
[key: string]: CliqueConfig | EthashConfig | CasperConfig;
};
/**
* Returns a deep copy of this {@link Common} instance.
*/
copy(): Common;
static _getInitializedChains(customChains?: ChainConfig_2[]): ChainsConfig;
}
/**
* Options for instantiating a {@link Common} instance.
*/
declare interface CommonOpts extends BaseOpts {
/**
* Chain name ('mainnet'), id (1), or {@link Chain} enum,
* either from a chain directly supported or a custom chain
* passed in via {@link CommonOpts.customChains}.
*/
chain: string | number | Chain | bigint | object;
/**
* Initialize (in addition to the supported chains) with the selected
* custom chains. Custom genesis state should be passed to the Blockchain class if used.
*
* Usage (directly with the respective chain initialization via the {@link CommonOpts.chain} option):
*
* ```javascript
* import myCustomChain1 from '[PATH_TO_MY_CHAINS]/myCustomChain1.json'
* const common = new Common({ chain: 'myCustomChain1', customChains: [ myCustomChain1 ]})
* ```
*/
customChains?: ChainConfig_2[];
}
declare type Comparator = (values: T[], a: number, b: number) => boolean;
/**
* The raw data for an ethereum transaction.
*/
declare type Concat = [...T, ...U];
declare function concatSig(v: Buffer, r: Buffer, s: Buffer): string;
declare class Connector