How to change manager in ASA?

I have no idea regarding the error please help

 // use assetID from Part 1
 let assetID = (22984338);
 // Change Asset Configuration:
 // Change the manager using an asset configuration transaction

 // First update changing transaction parameters
 // We will account for changing transaction parameters
 // before every transaction in this example

 params = await algodclient.getTransactionParams().do();
 //comment out the next two lines to use suggested fee
 //params.fee = 1000;
 //params.flatFee = true;
 // Asset configuration specific parameters
 // all other values are the same so we leave 
 // Them set.
 // specified address can change reserve, freeze, clawback, and manager
 manager = recoveredAccount1.addr;

 // Note that the change has to come from the existing manager
 let ctxn = algosdk.makeAssetConfigTxnWithSuggestedParams(recoveredAccount2.addr, note, 
     assetID, manager, reserve, freeze, clawback, params);

 // This transaction must be signed by the current manager
 rawSignedTxn = ctxn.signTxn(
 let ctx = (await algodclient.sendRawTransaction(rawSignedTxn).do());
 console.log("Transaction : " + ctx.txId);
 // wait for transaction to be confirmed
 await waitForConfirmation(algodclient, ctx.txId);

 // Get the asset information for the newly changed asset
 // use indexer or utiltiy function for Account info

 // The manager should now be the same as the creator
 await printCreatedAsset(algodclient, recoveredAccount1.addr, assetID);


G:\algo\algorand java\5ASA\changeman.js:10
 params = await algodclient.getTransactionParams().do();

SyntaxError: await is only valid in async function
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

Enclose your JavaScript example in an async function, then call it:

async function sample() {
... // your sample goes here

1 Like