Address malformed error

Hi this is my code for generate account and mint token

app.post('/generate-account', (req, res) => {
    const account = algosdk.generateAccount();
    const mnemonic = algosdk.secretKeyToMnemonic(account.sk);
    const address = account.addr;
    res.json({ mnemonic, address });
});

app.post('/mint-token', async(req, res) => {
    const { creatorMnemonic, creatorAddress, totalSupply, assetName, unitName, decimal } = req.body;

    try {
        // Get the suggested transaction parameters
        const suggestedParams = await algodClient.getTransactionParams().do();

        const { genesisHash } = suggestedParams; // Access genesisHash from suggestedParams

        console.log('Genesis Hash:', genesisHash);
        console.log('Suggested Parameters:', suggestedParams);

        // Validate the creatorAddress
        if (!algosdk.isValidAddress(creatorAddress)) {
            throw new Error('Invalid creatorAddress');
        }

        // Create the creator account
        const creatorAccount = algosdk.mnemonicToSecretKey(creatorMnemonic);

        // Create the asset creation transaction
        const txn = algosdk.makeAssetCreateTxnWithSuggestedParams(
            creatorAccount.addr,
            suggestedParams,
            unitName,
            assetName,
            creatorAccount.addr,
            creatorAccount.addr,
            creatorAccount.addr,
            creatorAccount.addr,
            'http://google.com',
            Number(totalSupply),
            Number(decimal),
        );

        // Sign the transaction
        const signedTxn = txn.signTxn(creatorAccount.sk);

        // Submit the transaction
        const txResponse = await algodClient.sendRawTransaction(signedTxn.blob).do();
        const assetId = txResponse.txId;

        res.json({ assetId });
    } catch (error) {
        console.log('Error:', error);
        res.status(500).json({ error: error.message });
    }
});

The error is : “error”: “address seems to be malformed”

How to resolve this?
If there is any link please share it with
me.
Thank you!

I think you’re missing one argument note, after the first argument of makeAssetCreateTxnWithSuggestedParams, which shifts all the other arguments.

I recommend using the newer functions makeAssetCreateTxnWithSuggestedParamsFromObject | algosdk that allows to specify arguments by names. See Algorand Standard Assets (ASAs) - Algorand Developer Portal

Thanks @fabrice try that!

Order of function params looks to be incorrect.
makeAssetCreateTxnWithSuggestedParams(from,note,assetTotal,assetDecimals,assetDefaultFrozen,assetManager,assetReserve,assetFreeze,assetClawback,assetUnitName,assetName,assetURL,assetMetadataHash,suggestedParams,reKeyTo);