Skip to main content

BtcRelay<V, T, B, Signer>

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:11

Represents a BTC relay bitcoin light client contract, which verifies the bitcoin blockheaders on smart chains

Type Parameters

Type ParameterDefault type
V extends BtcStoredHeader<any>-
T-
B extends BtcBlock-
Signer extends AbstractSignerAbstractSigner

Properties

maxForkHeadersPerTx

maxForkHeadersPerTx: number;

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:25

Maximum amount of fork headers that fit in a single transactions


maxHeadersPerTx

maxHeadersPerTx: number;

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:21

Maximum blockheaders that fit in a single transaction


maxShortForkHeadersPerTx?

optional maxShortForkHeadersPerTx: number;

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:29

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

Methods

estimateSynchronizeFee()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:166

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>


getFeePerBlock()

getFeePerBlock(feeRate?): Promise<bigint>;

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:173

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

Parameters

ParameterTypeDescription
feeRate?anyOptional fee rate to use for the estimation

Returns

Promise<bigint>


getForkFeeRate()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:158

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>


getMainFeeRate()

getMainFeeRate(signer): Promise<string>;

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:150

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>


getTipData()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:34

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

Returns

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


retrieveLatestKnownBlockLog()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:65

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

Returns

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


retrieveLogAndBlockheight()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:48

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; height: number; }
blockData.blockhashstring-
blockData.height?number-
requiredBlockheight?number

Returns

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


retrieveLogByCommitHash()

retrieveLogByCommitHash(commitHash, blockData): Promise<V>;

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:60

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

Parameters

ParameterTypeDescription
commitHashstring
blockData{ blockhash: string; height: number; }
blockData.blockhashstring-
blockData.heightnumber-

Returns

Promise<V>


saveForkHeaders()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:122

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

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
forkHeadersB[]New fork bitcoin blockheaders to submit
storedHeaderVCommitted 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: V[]; forkId: number; lastStoredHeader: V; tx: T; }>


saveInitialHeader()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:79

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<T>


saveMainHeaders()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:89

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
mainHeadersB[]New bitcoin blockheaders to submit
storedHeaderVLatest committed and stored bitcoin blockheader in the BTC relay
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: V[]; forkId: number; lastStoredHeader: V; tx: T; }>


saveNewForkHeaders()

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:105

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
forkHeadersB[]New fork bitcoin blockheaders to submit
storedHeaderVCommitted 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: V[]; forkId: number; lastStoredHeader: V; tx: T; }>


saveShortForkHeaders()?

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

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:138

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

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
forkHeadersB[]New fork bitcoin blockheaders to submit
storedHeaderVCommitted 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: V[]; forkId: number; lastStoredHeader: V; tx: T; }>


sweepForkData()?

optional sweepForkData(signer, lastSweepTimestamp?): Promise<number>;

Defined in: atomiq-base/src/btcrelay/BtcRelay.ts:183

Checks and sweeps data accounts which contain yet unused fork data (use for Solana's PDAs)

Parameters

ParameterTypeDescription
signerSignerA signer's address to check account for
lastSweepTimestamp?numberTimestamp of the last sweep

Returns

Promise<number>

A number of data accounts swept