/// import { RlpList } from 'rlp-stream'; /** A deserialized Ethereum block. */ export interface EthereumBlock { /** The header for the Ethereum block. */ header: EthereumHeader; /** The transaction list for the Ethereum block. */ transactions: EthereumTransaction[]; /** A list of headers for uncles. */ uncles: EthereumHeader[]; } export interface EthereumBlockDecoderOptions { /** For a EIP-155 transaction, which chain to use to replace v. */ chainId: number; /** * For decoding a block, which block number EIP-155 semantics automatically * applies. */ eip155Block: bigint; /** * For decoding a transaction, whether or not to use EIP-155 semantics to * decode the transaction. */ eip155: boolean; /** * If available, use native bindings to do transaction processing. */ native: boolean; } export declare const CONTRACT_CREATION: bigint; /** A header for an Ethereum block. */ export interface EthereumHeader { /** The Keccak 256-bit hash of the parent block’s header, in its entirety. */ parentHash: bigint; /** The Keccak 256-bit hash of the ommers list portion of this block. */ uncleHash: bigint; /** * The 160-bit address to which all fees collected from the successful mining * of this block be transferred. */ beneficiary: bigint; /** * The Keccak 256-bit hash of the root node of the state trie, after all * transactions are executed and finalisations applied. */ stateRoot: bigint; /** * The Keccak 256-bit hash of the root node of the trie structure populated * with each transaction in the transactions list portion of the block. */ transactionsRoot: bigint; /** * The Keccak 256-bit hash of the root node of the trie structure populated * with the receipts of each transaction in the transactions list portion of * the block. */ receiptsRoot: bigint; /** * The Bloom filter composed from indexable information (logger address and * log topics) contained in each log entry from the receipt of each * transaction in the transactions list. */ logsBloom: Buffer; /** * A scalar value corresponding to the difficulty level of this block. This * can be calculated from the previous block’s difficulty level and the * timestamp. */ difficulty: bigint; /** * A scalar value equal to the number of ancestor blocks. The genesis block * has a number of zero. */ blockNumber: bigint; /** * A scalar value equal to the current limit of gas expenditure per block. */ gasLimit: bigint; /** * A scalar value equal to the total gas used in transactions in this block. */ gasUsed: bigint; /** * A scalar value equal to the reasonable output of Unix’s time() at this * block’s inception. */ timestamp: bigint; /** * An arbitrary byte array containing data relevant to this block. This must * be 32 bytes or fewer. */ extraData: Buffer; /** * A 256-bit hash which proves combined with the nonce that a sufficient * amount of computation has been carried out on this block. */ mixHash: bigint; /** * A 64-bit hash which proves combined with the mix-hash that a sufficient * amount of computation has been carried out on this block. */ nonce: bigint; } /** The data stored in a block for a signed Ethereum transaction */ export interface EthereumTransaction { /** * A scalar value equal to the number of transactions sent from this address * or, in the case of accounts with associated code, the number of * contract-creations made by this account. */ nonce: bigint; /** * A scalar value equal to the number of Wei to be paid per unit of gas for * all computation costs incurred as a result of the execution of this * transaction. */ gasPrice: bigint; /** * A scalar value equal to the maximum amount of gas that should be used in * executing this transaction. */ gasLimit: bigint; /** * A scalar value equal to the number of Wei to be transferred to the message * call’s recipient or, in the case of contract creation, as an endowment to * the newly created account. */ value: bigint; /** * The 160-bit address of the message call’s recipient or, for a contract * creation transaction, CONTRACT_CREATION (-1), to distinguish against * account 0x0000000000000000000000000000000000000000. */ to: bigint; /** * An unlimited size byte array specifying the EVM-code for the account * initialisation procedure, for a contract transaction, or an unlimited size * byte array specifying the input data of the message call, for a message * call. */ data: Buffer; /** The 160-bit address of the message caller. */ from: bigint; } export declare class EthereumBlockDecoderError extends Error { constructor(message: string); } /** * Given a RLP-serialized list with an Ethereum header, decodes the list and * validates the Ethereum header. * * @param header The RLP-encoded list with the header to decode. * * @returns A validated and decoded EthereumHeader. */ export declare function decodeHeader(header: RlpList): EthereumHeader; /** * Given a RLP-serialized list with an Ethereum transaction, decodes the list * and validates the Ethereum transaction. * * @param header The RLP-encoded list with the transaction to decode. * * @returns A validated and decoded EthereumTransaction. */ export declare function decodeTransaction(transaction: RlpList, options?: EthereumBlockDecoderOptions): Promise; /** * Given a RLP-serialized list with an Ethereum block, decodes the list and * validates the Ethereum block. * * @param header The RLP-encoded list with the transaction to decode. * * @returns A validated and decoded EthereumTransaction. */ export declare function decodeBlock(rlp: RlpList, options?: EthereumBlockDecoderOptions): Promise; /** * Encodes an Ethereum header as a RLP list * * @param header The Ethreum header to encode. * * @return A RlpList with the encoded Ethereum header. */ export declare function encodeHeaderAsRLP(header: EthereumHeader): RlpList; /** * Encodes a new block. Transactions must be encoded and signed as a RLPList * * @param header The Ethreum header to encode. * @param transactions Encoded, signed transactions to include * @param uncleList A list of uncles to include * * @return A new RLP encoded Ethereum block. */ export declare function encodeBlock(header: EthereumHeader, transactions: RlpList, uncleList: EthereumHeader[]): Buffer; /** * Get the public address of a given private key. * * @param privateKey The private key to obtain an address for. It should be a * 256-bit bigint which cannot be 0. * @param useNativeIfAvailable Set to false to force fallback to js-only code. * * @return The public address for the given private key. */ export declare function getPublicAddress(privateKey: bigint, useNativeIfAvailable?: boolean): bigint | Promise; /** * Sign an [EthereumTransaction] using a private key. * * @param transaction The transaction to sign. The from field, if present, is * ignored (it will be derived from the private key) * @param privateKey The private key to sign the transaction with. * @param chainId The chain id to use. 0=pre EIP-155 semantics. 1=mainnet. * @param useNativeIfAvailable Set to false to force fallback to js-only code. * * @return A [RlpList] representing the transaction. Run this list through * RlpEncode to obtain a [Buffer]. */ export declare function signTransaction(transaction: EthereumTransaction, privateKey: bigint, chainId?: number, useNativeIfAvailable?: boolean): RlpList;