Skip to main content

EVMBtcRelay<B>

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:34

EVM BTC Relay bitcoin light client contract representation.

Extends

  • EVMContractBase<BtcRelayTypechain>

Type Parameters

Type Parameter
B extends BtcBlock

Implements

Constructors

Constructor

new EVMBtcRelay<B>(
chainInterface,
bitcoinRpc,
bitcoinNetwork,
contractAddress,
contractDeploymentHeight?): EVMBtcRelay<B>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:112

Parameters

ParameterType
chainInterfaceEVMChainInterface<any>
bitcoinRpcBitcoinRpc<B>
bitcoinNetworkBitcoinNetwork
contractAddressstring
contractDeploymentHeight?number

Returns

EVMBtcRelay<B>

Overrides

EVMContractBase<BtcRelayTypechain>.constructor

Properties

_bitcoinRpc

readonly _bitcoinRpc: BitcoinRpc<B>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:106


contract

readonly contract: BtcRelay;

Defined in: atomiq-chain-evm/src/evm/contract/EVMContractBase.ts:33

Inherited from

EVMContractBase.contract

maxForkHeadersPerTx

readonly maxForkHeadersPerTx: number = 50;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:109

Maximum amount of fork headers that fit in a single transactions

Implementation of

BtcRelay.maxForkHeadersPerTx


maxHeadersPerTx

readonly maxHeadersPerTx: number = 100;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:108

Maximum blockheaders that fit in a single transaction

Implementation of

BtcRelay.maxHeadersPerTx


maxShortForkHeadersPerTx

readonly maxShortForkHeadersPerTx: number = 100;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:110

Maximum amount of fork headers that can be submitted at once using the short fork method

Implementation of

BtcRelay.maxShortForkHeadersPerTx


Chain

protected readonly Chain: EVMChainInterface<any>;

Defined in: atomiq-chain-evm/src/evm/contract/EVMContractBase.ts:39

Inherited from

EVMContractBase.Chain

Methods

estimateSynchronizeFee()

estimateSynchronizeFee(requiredBlockheight, feeRate?): Promise<bigint>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:431

Estimate required synchronization fee (worst case) to synchronize btc relay to the required blockheight

Parameters

ParameterTypeDescription
requiredBlockheightnumberBlockheight to which to synchronize
feeRate?stringOptional fee rate to use for the estimation

Returns

Promise<bigint>

Implementation of

BtcRelay.estimateSynchronizeFee


getFeePerBlock()

getFeePerBlock(feeRate?): Promise<bigint>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:453

Returns required fee in native token to synchronize a single block to btc relay

Parameters

ParameterTypeDescription
feeRate?stringOptional fee rate to use for the estimation

Returns

Promise<bigint>

Implementation of

BtcRelay.getFeePerBlock


getForkFeeRate()

getForkFeeRate(signer, forkId): Promise<string>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:468

Gets fee rate required for submitting blockheaders to the specific fork

Parameters

ParameterTypeDescription
signerstringA signer's address to use for the estimation
forkIdnumberA fork ID to use for estimation

Returns

Promise<string>

Implementation of

BtcRelay.getForkFeeRate


getMainFeeRate()

getMainFeeRate(signer): Promise<string>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:461

Gets fee rate required for submitting blockheaders to the main chain

Parameters

ParameterTypeDescription
signerstringA signer's address to use for the estimation

Returns

Promise<string>

Implementation of

BtcRelay.getMainFeeRate


getTipData()

getTipData(): Promise<{
blockhash: string;
blockheight: number;
chainWork: Buffer;
commitHash: string;
}>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:263

Returns data about current main chain tip stored in the btc relay

Returns

Promise<{ blockhash: string; blockheight: number; chainWork: Buffer; commitHash: string; }>

Implementation of

BtcRelay.getTipData


retrieveLatestKnownBlockLog()

retrieveLatestKnownBlockLog(): Promise<{
resultBitcoinHeader: B;
resultStoredHeader: EVMBtcStoredHeader;
}>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:329

Retrieves latest known bitcoin blockheader stored in the BTC Relay and also known to the bitcoin RPC

Returns

Promise<{ resultBitcoinHeader: B; resultStoredHeader: EVMBtcStoredHeader; }>

Implementation of

BtcRelay.retrieveLatestKnownBlockLog


retrieveLogAndBlockheight()

retrieveLogAndBlockheight(blockData, requiredBlockheight?): Promise<{
header: EVMBtcStoredHeader;
height: number;
}>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:283

Retrieves blockheader with a specific blockhash, returns null if requiredBlockheight is provided and btc relay contract is not synced up to the desired blockheight

Parameters

ParameterTypeDescription
blockData{ blockhash: string; }
blockData.blockhashstring-
requiredBlockheight?number

Returns

Promise<{ header: EVMBtcStoredHeader; height: number; }>

Implementation of

BtcRelay.retrieveLogAndBlockheight


retrieveLogByCommitHash()

retrieveLogByCommitHash(commitmentHashStr, blockData): Promise<EVMBtcStoredHeader>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:310

Retrieves stored bitcoin blockheader data by blockheader's commit hash and provided blockhash from blockData

Parameters

ParameterTypeDescription
commitmentHashStrstring
blockData{ blockhash: string; }
blockData.blockhashstring-

Returns

Promise<EVMBtcStoredHeader>

Implementation of

BtcRelay.retrieveLogByCommitHash


saveForkHeaders()

saveForkHeaders(
signer,
forkHeaders,
storedHeader,
forkId,
tipWork,
feeRate?): Promise<{
computedCommitedHeaders: EVMBtcStoredHeader[];
forkId: number;
lastStoredHeader: EVMBtcStoredHeader;
tx: TransactionRequest;
}>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:397

Returns a transaction that continues submitting blockheaders to an existing long fork

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
forkHeadersBtcBlock[]New fork bitcoin blockheaders to submit
storedHeaderEVMBtcStoredHeaderCommitted and stored bitcoin blockheader in the BTC relay from which to fork
forkIdnumberFork ID to submit the blockheaders to
tipWorkBufferChainwork of the current BTC Relay main chain tip
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: EVMBtcStoredHeader[]; forkId: number; lastStoredHeader: EVMBtcStoredHeader; tx: TransactionRequest; }>

Implementation of

BtcRelay.saveForkHeaders


saveInitialHeader()

saveInitialHeader(
signer,
header,
epochStart,
pastBlocksTimestamps,
feeRate?): Promise<TransactionRequest>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:475

Initializes the underlying BTC Relay contract

Parameters

ParameterTypeDescription
signerstringA signer's address to use for the transaction
headerBMain chain blockheader to use as a genesis
epochStartnumberTimestamp of the first block in this difficulty epoch
pastBlocksTimestampsnumber[]Timestamps of the last 11 blockheaders, for median block time rule
feeRate?stringOptional fee rate for the transaction

Returns

Promise<TransactionRequest>

Implementation of

BtcRelay.saveInitialHeader


saveMainHeaders()

saveMainHeaders(
signer,
mainHeaders,
storedHeader,
feeRate?): Promise<{
computedCommitedHeaders: EVMBtcStoredHeader[];
forkId: number;
lastStoredHeader: EVMBtcStoredHeader;
tx: TransactionRequest;
}>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:370

Returns a transaction that submits bitcoin blockheaders as a bitcoin main chain to the btc relay

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
mainHeadersBtcBlock[]New bitcoin blockheaders to submit
storedHeaderEVMBtcStoredHeaderLatest committed and stored bitcoin blockheader in the BTC relay
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: EVMBtcStoredHeader[]; forkId: number; lastStoredHeader: EVMBtcStoredHeader; tx: TransactionRequest; }>

Implementation of

BtcRelay.saveMainHeaders


saveNewForkHeaders()

saveNewForkHeaders(
signer,
forkHeaders,
storedHeader,
tipWork,
feeRate?): Promise<{
computedCommitedHeaders: EVMBtcStoredHeader[];
forkId: number;
lastStoredHeader: EVMBtcStoredHeader;
tx: TransactionRequest;
}>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:379

Returns a transaction that submits a new long fork and submits the first headers to it

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
forkHeadersBtcBlock[]New fork bitcoin blockheaders to submit
storedHeaderEVMBtcStoredHeaderCommitted and stored bitcoin blockheader in the BTC relay from which to fork
tipWorkBufferChainwork of the current BTC Relay main chain tip
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: EVMBtcStoredHeader[]; forkId: number; lastStoredHeader: EVMBtcStoredHeader; tx: TransactionRequest; }>

Implementation of

BtcRelay.saveNewForkHeaders


saveShortForkHeaders()

saveShortForkHeaders(
signer,
forkHeaders,
storedHeader,
tipWork,
feeRate?): Promise<{
computedCommitedHeaders: EVMBtcStoredHeader[];
forkId: number;
lastStoredHeader: EVMBtcStoredHeader;
tx: TransactionRequest;
}>;

Defined in: atomiq-chain-evm/src/evm/btcrelay/EVMBtcRelay.ts:414

Returns a transaction that submits a short fork with the provided blockheaders

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
forkHeadersBtcBlock[]New fork bitcoin blockheaders to submit
storedHeaderEVMBtcStoredHeaderCommitted and stored bitcoin blockheader in the BTC relay from which to fork
tipWorkBufferChainwork of the current BTC Relay main chain tip
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: EVMBtcStoredHeader[]; forkId: number; lastStoredHeader: EVMBtcStoredHeader; tx: TransactionRequest; }>

Implementation of

BtcRelay.saveShortForkHeaders