-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { BitcoinRpcProvider, UtuProvider } from "bitcoin-on-starknet"; | ||
|
||
async function main() { | ||
// Initialize the Bitcoin RPC provider | ||
const bitcoinProvider = new BitcoinRpcProvider({ | ||
url: process.env.BITCOIN_RPC_URL || "http://localhost:8332", | ||
username: process.env.BITCOIN_RPC_USERNAME, | ||
password: process.env.BITCOIN_RPC_PASSWORD, | ||
}); | ||
|
||
// Initialize the Utu provider with the Bitcoin provider | ||
const utuProvider = new UtuProvider(bitcoinProvider); | ||
|
||
try { | ||
// Get proof for block height 800000 | ||
console.log("Getting proof for block 800000..."); | ||
const proof = await utuProvider.getBlockHeightProof(800000); | ||
console.log("Block header:", proof.blockHeader); | ||
console.log("Raw coinbase transaction:", proof.rawCoinbaseTx); | ||
console.log("Merkle proof length:", proof.merkleProof.length); | ||
|
||
// Get register blocks transaction | ||
const blockHash = | ||
"00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee"; | ||
console.log("\nGetting register blocks transaction..."); | ||
const registerTx = await utuProvider.getRegisterBlocksTx([blockHash]); | ||
console.log("Contract address:", registerTx.contractAddress); | ||
console.log("Selector:", registerTx.selector); | ||
console.log("Calldata length:", registerTx.calldata.length); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export * from "@/BitcoinProvider"; | ||
export * from "@/BitcoinRpcProvider"; | ||
export * from "@/UtuProvider"; | ||
export * from "@/BitcoinTypes"; | ||
export * from "@/UtuTypes"; |