-
Notifications
You must be signed in to change notification settings - Fork 23
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
1 parent
42c7cb4
commit a521da9
Showing
3 changed files
with
42 additions
and
37 deletions.
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
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,35 +1,32 @@ | ||
// In this example we: | ||
// - prepare the provider, wallet, blaze, | ||
// - build a transaction paying out 50 ada to Micah's Wallet | ||
// - sign & submit that transaction | ||
import { HotWallet, Core, Blaze, Maestro } from '@blazecardano/sdk' | ||
let pkhHex = '... the public key hex ...' | ||
import { ColdWallet, Core, Blaze, Maestro } from "@blaze-cardano/sdk"; | ||
import * as readline from "node:readline/promises"; | ||
import { stdin, stdout } from "node:process"; | ||
const rl = readline.createInterface({ input: stdin, output: stdout }); | ||
|
||
await setTimeout(() => {}, 1000); | ||
|
||
let address = Core.addressFromBech32( | ||
await rl.question("Please enter your bech32 cardano address: "), | ||
); | ||
|
||
// $butane wallet can collect donations for us | ||
const micahWallet = Core.addressFromBech32( | ||
'addr1qye93uefq8r6ezk0kzq443u9zht7ylu5nelvw8eracd200ylzvhpxn9c4g2fyxe5rlmn6z5qmm3dtjqfjn2vvy58l88szlpjw4', | ||
) | ||
const blazeWallet = Core.addressFromBech32( | ||
"addr1qye93uefq8r6ezk0kzq443u9zht7ylu5nelvw8eracd200ylzvhpxn9c4g2fyxe5rlmn6z5qmm3dtjqfjn2vvy58l88szlpjw4", | ||
); | ||
|
||
const provider = new Maestro({ | ||
network: 'mainnet', | ||
apiKey: '...your maestro api key...', | ||
}) | ||
const wallet = new HotWallet( | ||
Core.Ed25519PrivateNormalKeyHex(pkhHex), | ||
0, | ||
provider, | ||
) | ||
console.log('Your blaze address: ', wallet.address.toBech32()) | ||
const blaze = new Blaze( | ||
provider, | ||
new HotWallet(Core.Ed25519PrivateNormalKeyHex(pkhHex), 0, provider), | ||
) | ||
network: "mainnet", | ||
apiKey: await rl.question("Please enter your mainnet maestro key: "), | ||
}); | ||
const wallet = new ColdWallet(address, 0, provider); | ||
|
||
console.log("Your blaze address: ", wallet.address.toBech32()); | ||
const blaze = new Blaze(provider, wallet); | ||
|
||
//Use the awesome transaction builder | ||
const tx = await(await blaze.newTransaction()) | ||
.payLovelace(micahWallet, 5n * 1_000_000n) | ||
.complete() | ||
// Attach signatures (scuffed as fuck) | ||
const signed = await wallet.signTransaction(tx) | ||
let ws = tx.witnessSet() | ||
ws.setVkeys(signed.vkeys()!) | ||
tx.setWitnessSet(ws) | ||
// Post transaction to the chain | ||
console.log(await blaze.provider.postTransactionToChain(tx)) | ||
const tx = await (await blaze.newTransaction()) | ||
.payLovelace(blazeWallet, 5n * 1_000_000n) | ||
.complete(); | ||
|
||
// Dump the transaction for you to submit securely | ||
console.log(`Please sign and submit this transaction: ${tx.toCbor()}`); |
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