Skip to content

Commit

Permalink
chore: correct example
Browse files Browse the repository at this point in the history
  • Loading branch information
micahkendall committed May 5, 2024
1 parent 42c7cb4 commit a521da9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 37 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ npm i @blaze-cardano/sdk
// In this example we:
// - prepare the provider (Maestro), wallet, blaze,
// - build a transaction paying out 50 ada to an external wallet
// - sign & submit that transaction
// - dump the transaction cbor
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(
prompt("Please enter your bech32 cardano address: "),
await rl.question("Please enter your bech32 cardano address: "),
);

// $butane wallet can collect donations for us
Expand All @@ -41,9 +46,8 @@ const blazeWallet = Core.addressFromBech32(

const provider = new Maestro({
network: "mainnet",
apiKey: prompt("Please enter your mainnet maestro key: "),
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());
Expand Down
61 changes: 29 additions & 32 deletions examples/send_lovelace.ts
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()}`);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "blaze",
"type": "module",
"module": "index.ts",
"workspaces": ["packages/*"],
"workspaces": [
"packages/*"
],
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev --parallel",
Expand All @@ -16,6 +19,7 @@
"devDependencies": {
"@blaze-cardano/eslint-config": "workspace:*",
"@blaze-cardano/tsconfig": "workspace:*",
"@blaze-cardano/sdk": "workspace:*",
"@changesets/cli": "^2.27.1",
"@types/jest": "^29.5.5",
"@types/node": "^20.12.7",
Expand Down

0 comments on commit a521da9

Please sign in to comment.