You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a code example. I tried the same document, but I still got an issue: Transaction successful: {"status":"ERROR","hash":"9a707f5b4f49b35313c6ed26cf2f3988a7cf9f06baf124c6e802db37996694f7","latestLedger":496366,"latestLedgerCloseTime":"1720750899","errorResult":{"_attributes":{"feeCharged":{"_value":"0"},"result":{"_switch":{"name":"txMalformed","value":-16}},"ext":{"_switch":0}}}}
I don't know if it is a bug or an issue in my code :(( I used stellar-sdk version 12.1.0 and node version 22.3.0
import{TransactionBuilder,Keypair,BASE_FEE,TimeoutInfinite,Contract,Address,scValToNative,SorobanRpc,xdr,nativeToScVal,Networks,}from'stellar-sdk';importStellarHDWalletfrom'stellar-hd-wallet';try{constwallet=StellarHDWallet.fromMnemonic('passphare');// Derive key pairconstkeyPair=Keypair.fromSecret(wallet.getSecret(0));// const keyPair = Keypair.fromRawEd25519Seed(derivedKey.privateKey);console.log('Public key:',keyPair.publicKey());// Get the source keypairconsole.log('Source keypair loaded:',keyPair.publicKey());// Load the source accountconstaccount=awaitserver.getAccount(keyPair.publicKey());console.log('Source account loaded:',account.accountId());// Create a transaction builderconsttransactionBuilder=newTransactionBuilder(account,{fee: BASE_FEE,networkPassphrase: Networks.TESTNET,});constcontract=newContract('SMART_CONTRACT_ADDRESS');// Add the operation to the transactiontransactionBuilder.addOperation(contract.call('set_user',newAddress(wallet_address).toScVal(),nativeToScVal(WalletStatusEnum.APPROVED,{type: 'u32'}),),);console.log('Operation added to the transaction');// Set timeouttransactionBuilder.setTimeout(TimeoutInfinite);// Build the transactionconsttx=transactionBuilder.build();// Sign the transactiontx.sign(keyPair);console.log('Transaction built:',JSON.stringify(tx));// Check if signatures are properly addedif(!tx.signatures||tx.signatures.length===0){thrownewError('Transaction not signed correctly');}consttransactionXDR=tx.toEnvelope().toXDR('base64');console.log('Transaction XDR:',transactionXDR);// Submit the transactionconstsendResponse=awaitserver.sendTransaction(tx);console.log('Transaction successful:',JSON.stringify(sendResponse));if(sendResponse.status==='PENDING'){lettxResponse=awaitserver.getTransaction(sendResponse.hash);// Poll this until the status is not "NOT_FOUND"while(txResponse.status==='NOT_FOUND'){// See if the transaction is completetxResponse=awaitserver.getTransaction(sendResponse.hash);// Wait a secondawaitnewPromise((resolve)=>setTimeout(resolve,1000));}returnsendResponse.hash;}else{thrownewError(`Unabled to submit transaction, status: ${sendResponse.status}`,);}}catch(error){console.error('Error preparing or sending transaction:',error?.message);throwerror;}
The text was updated successfully, but these errors were encountered:
I have a code example. I tried the same document, but I still got an issue:
Transaction successful: {"status":"ERROR","hash":"9a707f5b4f49b35313c6ed26cf2f3988a7cf9f06baf124c6e802db37996694f7","latestLedger":496366,"latestLedgerCloseTime":"1720750899","errorResult":{"_attributes":{"feeCharged":{"_value":"0"},"result":{"_switch":{"name":"txMalformed","value":-16}},"ext":{"_switch":0}}}}
I don't know if it is a bug or an issue in my code :(( I used stellar-sdk version 12.1.0 and node version 22.3.0
The text was updated successfully, but these errors were encountered: