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 Parameter | Default type |
|---|---|
V extends BtcStoredHeader<any> | - |
T | - |
B extends BtcBlock | - |
Signer extends AbstractSigner | AbstractSigner |
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
| Parameter | Type | Description |
|---|---|---|
requiredBlockheight | number | Blockheight to which to synchronize |
feeRate? | string | Optional 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
| Parameter | Type | Description |
|---|---|---|
feeRate? | any | Optional 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
| Parameter | Type | Description |
|---|---|---|
signer | string | A signer's address to use for the estimation |
forkId | number | A 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
| Parameter | Type | Description |
|---|---|---|
signer | string | A 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
| Parameter | Type | Description |
|---|---|---|
blockData | { blockhash: string; height: number; } | |
blockData.blockhash | string | - |
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
| Parameter | Type | Description |
|---|---|---|
commitHash | string | |
blockData | { blockhash: string; height: number; } | |
blockData.blockhash | string | - |
blockData.height | number | - |
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
| Parameter | Type | Description |
|---|---|---|
signer | string | A signer's address for the transaction |
forkHeaders | B[] | New fork bitcoin blockheaders to submit |
storedHeader | V | Committed and stored bitcoin blockheader in the BTC relay from which to fork |
forkId | number | Fork ID to submit the blockheaders to |
tipWork | Buffer | Chainwork of the current BTC Relay main chain tip |
feeRate? | string | Optional 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
| Parameter | Type | Description |
|---|---|---|
signer | string | A signer's address to use for the transaction |
header | B | Main chain blockheader to use as a genesis |
epochStart | number | Timestamp of the first block in this difficulty epoch |
pastBlocksTimestamps | number[] | Timestamps of the last 11 blockheaders, for median block time rule |
feeRate? | string | Optional 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
| Parameter | Type | Description |
|---|---|---|
signer | string | A signer's address for the transaction |
mainHeaders | B[] | New bitcoin blockheaders to submit |
storedHeader | V | Latest committed and stored bitcoin blockheader in the BTC relay |
feeRate? | string | Optional 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
| Parameter | Type | Description |
|---|---|---|
signer | string | A signer's address for the transaction |
forkHeaders | B[] | New fork bitcoin blockheaders to submit |
storedHeader | V | Committed and stored bitcoin blockheader in the BTC relay from which to fork |
tipWork | Buffer | Chainwork of the current BTC Relay main chain tip |
feeRate? | string | Optional 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
| Parameter | Type | Description |
|---|---|---|
signer | string | A signer's address for the transaction |
forkHeaders | B[] | New fork bitcoin blockheaders to submit |
storedHeader | V | Committed and stored bitcoin blockheader in the BTC relay from which to fork |
tipWork | Buffer | Chainwork of the current BTC Relay main chain tip |
feeRate? | string | Optional 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
| Parameter | Type | Description |
|---|---|---|
signer | Signer | A signer's address to check account for |
lastSweepTimestamp? | number | Timestamp of the last sweep |
Returns
Promise<number>
A number of data accounts swept