1- import { Sdk , initSdk } from "@namada/sdk-node" ;
1+ import BigNumber from "bignumber.js" ;
2+ import { Sdk , WrapperTxProps , initSdk } from "@namada/sdk-node" ;
23
34const initializeSdk = async ( ) : Promise < Sdk > => {
4- const rpcUrl = "https://rpc.housefire.tududes.com " ;
5+ const rpcUrl = "https://rpc.mainnet.siuuu.click " ;
56 const token = "tnam1q9gr66cvu4hrzm0sd5kmlnjje82gs3xlfg3v6nu7" ;
6- const maspIndexerUrl = "https://masp.housefire.tududes.com " ;
7+ const maspIndexerUrl = "https://masp.mainnet.siuuu.click " ;
78 const dbName = "testDb" ;
89
910 const sdk = await initSdk ( { rpcUrl, token, maspIndexerUrl, dbName } ) ;
@@ -17,6 +18,40 @@ const app = async () => {
1718 console . log ( "Native token:" , nativeToken ) ;
1819 const validators = await sdk . rpc . queryAllValidators ( ) ;
1920 console . log ( "Validators:" , validators ) ;
21+ await broadcastTransferTx ( sdk ) ;
2022} ;
2123
2224app ( ) . then ( ( ) => console . log ( "IT WORKED!" ) ) ;
25+
26+ const broadcastTransferTx = async ( sdk : Sdk ) => {
27+ const wrapperTxProps : WrapperTxProps = {
28+ token : "tnam1q9gr66cvu4hrzm0sd5kmlnjje82gs3xlfg3v6nu7" ,
29+ feeAmount : BigNumber ( "0.000001" ) ,
30+ gasLimit : BigNumber ( "62500" ) ,
31+ chainId : "namada.5f5de2dd1b88cba30586420" ,
32+ publicKey :
33+ "tpknam1qpam035talr4f8qgltku73dl6zr3t6p22t39w74qatpcecfxgkhgw8tktev" , // replace with actual public key
34+ } ;
35+ const transferProps = {
36+ data : [
37+ {
38+ source : "tnam1qrxsru5rdu4he400xny6p779fcw7xuftsgjnmzup" , // replace with actual source address
39+ target : "tnam1qpqfsmj2quxnakfq0rn8y2tjcvtz26f8pyw4fq98" , // replace with actual target address
40+ token : "tnam1q9gr66cvu4hrzm0sd5kmlnjje82gs3xlfg3v6nu7" ,
41+ amount : BigNumber ( "0.00001" ) ,
42+ } ,
43+ ] ,
44+ } ;
45+ const tx = await sdk
46+ . getTx ( )
47+ . buildTransparentTransfer ( wrapperTxProps , transferProps ) ;
48+ console . log ( "Built Tx:" , tx ) ;
49+ const signedTx = await sdk . getSigning ( ) . sign (
50+ tx ,
51+ "4d4c31e159acffa2ab5983d953f56ef4d9375538eb7f030cff538dd58e197097" , // replace with actual private key
52+ ) ;
53+ console . log ( "Signed Tx:" , signedTx ) ;
54+ console . log ( "Broadcasting Tx..., it might take a while" ) ;
55+ const response = await sdk . getRpc ( ) . broadcastTx ( signedTx ) ;
56+ console . log ( "Broadcast Response:" , response ) ;
57+ } ;
0 commit comments