@@ -77,30 +77,28 @@ This example shows how to create and submit a fee-bump transaction on the Stella
7777<CodeExample >
7878
7979``` js
80- import * as StellarSDK from " @stellar/stellar-sdk" ;
80+ import * as StellarSdk from " @stellar/stellar-sdk" ;
8181
8282// Define the network passphrase (use 'Testnet' for testing and 'Public Global Stellar Network ; September 2015' for production)
83- const networkPassphrase = StellarSDK .Networks .TESTNET ;
83+ const networkPassphrase = StellarSdk .Networks .TESTNET ;
8484
8585// Create keypairs for the source account and the fee account
86- const sourceKeypair = StellarSDK .Keypair .fromSecret (" SECREY_KEY_1" );
87- const feeKeypair = StellarSDK .Keypair .fromSecret (" SECREY_KEY_2" );
86+ const sourceKeypair = StellarSdk .Keypair .fromSecret (" SECREY_KEY_1" );
87+ const feeKeypair = StellarSdk .Keypair .fromSecret (" SECREY_KEY_2" );
8888
8989// Load the source account (this requires network interaction)
90- const server = new StellarSDK.Horizon.Server (
91- " https://horizon-testnet.stellar.org" ,
92- );
93- const sourceAccount = await server .loadAccount (sourceKeypair .publicKey ());
90+ const server = new StellarSdk.rpc.Server (" https://soroban-testnet.stellar.org" );
91+ const sourceAccount = await server .getAccount (sourceKeypair .publicKey ());
9492
9593// Construct the inner transaction, just a example tx, to transfer 10 XLM to a destination account
96- const innerTransaction = new StellarSDK .TransactionBuilder (sourceAccount, {
97- fee: StellarSDK .BASE_FEE ,
94+ const innerTransaction = new StellarSdk .TransactionBuilder (sourceAccount, {
95+ fee: StellarSdk .BASE_FEE ,
9896 networkPassphrase,
9997})
10098 .addOperation (
101- StellarSDK .Operation .payment ({
99+ StellarSdk .Operation .payment ({
102100 destination: " GDWH3P3MNTCMOY42CA7RVEACUUAUPZ73XDYKPYUL3TWOFRF37FD6OVM6" ,
103- asset: StellarSDK .Asset .native (),
101+ asset: StellarSdk .Asset .native (),
104102 amount: " 10" ,
105103 }),
106104 )
@@ -112,9 +110,9 @@ innerTransaction.sign(sourceKeypair);
112110
113111// Build the fee-bump transaction
114112const feeBumpTransaction =
115- StellarSDK .TransactionBuilder .buildFeeBumpTransaction (
113+ StellarSdk .TransactionBuilder .buildFeeBumpTransaction (
116114 feeKeypair,
117- StellarSDK .BASE_FEE * 2 ,
115+ StellarSdk .BASE_FEE * 2 ,
118116 innerTransaction,
119117 networkPassphrase,
120118 );
@@ -124,9 +122,19 @@ feeBumpTransaction.sign(feeKeypair);
124122
125123// Submit the fee-bump transaction to the Stellar network
126124server
127- .submitTransaction (feeBumpTransaction)
125+ .sendTransaction (feeBumpTransaction)
128126 .then ((response ) => {
129- console .log (" Success! Results:" , response);
127+ if (response .status !== " PENDING" ) {
128+ throw response;
129+ }
130+
131+ return server .pollTransaction (response .hash , {
132+ sleepStrategy: StellarSdk .rpc .LinearSleepStrategy ,
133+ attempts: 5 ,
134+ });
135+ })
136+ .then ((response ) => {
137+ console .log (" transaction response:" , response);
130138 })
131139 .catch ((error ) => {
132140 console .error (" Something went wrong!" , error);
0 commit comments