This forum is a read-only archive. Posting, replying and signing in are disabled.

Address malformed error

isha

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!

humblefool

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