Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(),
);
};