From 54f8657c99cdd0cd15a4ee605a39e9d2e06723c1 Mon Sep 17 00:00:00 2001 From: Mateusz Jasiuk Date: Thu, 4 Dec 2025 12:42:53 +0100 Subject: [PATCH] feat: example logs --- node/src/index.ts | 53 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/node/src/index.ts b/node/src/index.ts index dc8b041..ea48d8a 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -23,25 +23,46 @@ const app = async () => { app().then(() => console.log("IT WORKED!")); +const NATIVE_TOKEN = "tnam1q9gr66cvu4hrzm0sd5kmlnjje82gs3xlfg3v6nu7"; +const CHAIN_ID = "namada.5f5de2dd1b88cba30586420"; const broadcastTransferTx = async (sdk: Sdk) => { const wrapperTxProps: WrapperTxProps = { - token: "tnam1q9gr66cvu4hrzm0sd5kmlnjje82gs3xlfg3v6nu7", - feeAmount: BigNumber("0.000001"), - gasLimit: BigNumber("62500"), - chainId: "namada.5f5de2dd1b88cba30586420", + token: NATIVE_TOKEN, + feeAmount: BigNumber(0.000001), + gasLimit: BigNumber(62500), + chainId: CHAIN_ID, publicKey: - "tpknam1qpam035talr4f8qgltku73dl6zr3t6p22t39w74qatpcecfxgkhgw8tktev", // replace with actual public key + "tpknam1qpam035talr4f8qgltku73dl6zr3t6p22t39w74qatpcecfxgkhgw8tktev", }; + const transferProps = { data: [ { - source: "tnam1qrxsru5rdu4he400xny6p779fcw7xuftsgjnmzup", // replace with actual source address - target: "tnam1qpqfsmj2quxnakfq0rn8y2tjcvtz26f8pyw4fq98", // replace with actual target address + source: "tnam1qrxsru5rdu4he400xny6p779fcw7xuftsgjnmzup", + target: "tnam1qrz2lcz9dc6g4262gg73ar0rl5fqmtth5gneh62e", token: "tnam1q9gr66cvu4hrzm0sd5kmlnjje82gs3xlfg3v6nu7", - amount: BigNumber("0.00001"), + amount: BigNumber(1), }, ], }; + // const wrapperTxProps: WrapperTxProps = { + // token: "tnam1q9gr66cvu4hrzm0sd5kmlnjje82gs3xlfg3v6nu7", + // feeAmount: BigNumber("0.000001"), + // gasLimit: BigNumber("62500"), + // chainId: "namada.5f5de2dd1b88cba30586420", + // publicKey: + // "tpknam1qpam035talr4f8qgltku73dl6zr3t6p22t39w74qatpcecfxgkhgw8tktev", // replace with actual public key + // }; + // const transferProps = { + // data: [ + // { + // source: "tnam1qrxsru5rdu4he400xny6p779fcw7xuftsgjnmzup", // replace with actual source address + // target: "tnam1qpqfsmj2quxnakfq0rn8y2tjcvtz26f8pyw4fq98", // replace with actual target address + // token: "tnam1q9gr66cvu4hrzm0sd5kmlnjje82gs3xlfg3v6nu7", + // amount: BigNumber("0.00001"), + // }, + // ], + // }; const tx = await sdk .getTx() .buildTransparentTransfer(wrapperTxProps, transferProps); @@ -52,6 +73,22 @@ const broadcastTransferTx = async (sdk: Sdk) => { ); console.log("Signed Tx:", signedTx); console.log("Broadcasting Tx..., it might take a while"); + const balance = await sdk.rpc.queryBalance( + "tnam1qrxsru5rdu4he400xny6p779fcw7xuftsgjnmzup", + [NATIVE_TOKEN], + CHAIN_ID, + ); + console.log("Balance before tx:", balance); const response = await sdk.getRpc().broadcastTx(signedTx); console.log("Broadcast Response:", response); + const balanceAfter = await sdk.rpc.queryBalance( + "tnam1qrxsru5rdu4he400xny6p779fcw7xuftsgjnmzup", + [NATIVE_TOKEN], + CHAIN_ID, + ); + console.log("Balance after tx:", balanceAfter); + console.log( + "Balance difference:", + BigNumber(balanceAfter[0][1])!.minus(balance[0][1]!).toString(), + ); };