Error occur while send Algos from My Account to Another Account

Hi All,
I am trying to Transfer Algos from one account to another account. whenever I transfer I need to give a mnemonic in my contract code. if I give my wallet address directly rises some error.
this is my code:-

function recoverAccount1(){
** const passphrase = “YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY”;**
** let myAccount = algosdk.mnemonicToSecretKey(passphrase);**
** return myAccount;**
}
error message

(My account A address: undefined
err Error: address seems to be malformed
** at Object.decodeAddress (D:\GitAlgo1\docs\examples\atomic_transfers\v2\javascript\node_modules\algosdk\dist\cjs\src\encoding\address.js:61:15) **
** at new Transaction (D:\GitAlgo1\docs\examples\atomic_transfers\v2\javascript\node_modules\algosdk\dist\cjs\src\transaction.js:88:28)**
** at Object.makePaymentTxnWithSuggestedParams (D:\GitAlgo1\docs\examples\atomic_transfers\v2\javascript\node_modules\algosdk\dist\cjs\src\makeTxn.js:54:12)**
** at submitGroupTransactions (D:\GitAlgo1\docs\examples\atomic_transfers\v2\javascript\atomicTransfer.js:80:36)**
** at processTicksAndRejections (node:internal/process/task_queues:94:5)** )

Usually it means that the address is incorrect.
Is the address you are using of the following form:
MSAIXPDO552NEV4WWDUZIGKV6ST6JHCYQ7TDIJEZQY45TUEPTOET42QX7A?
(string of same length with only characters in the base32 set)

Can you give an example that we can execute and that is as short as possible with this problem?
You may either write it between triple backquotes ‘’’ or link to a Github Gist.

thanks for the response
Hi @fabrice
How to transfer my Asset or Algos using my wallet address in reactjs(javascript).if possible?
can you give a sample code or Github?

I would start without react and do: 3. Your First Transaction - Algorand Developer Portal

Thanks for the response
Hi @fabrice
I already try this method. I put my mnemonic this process works done. but I put my wallet address its does not work properly?

It would be very helpful if you could show a minimal version of your code that does not work.

To develop in React, you need to decide where to store the user keys.
You may want to consider using AlgoSigner, MyAlgoConnect or Aikon ORE ID.

Hi @fabrice
Thanks for the response.
I try this below Github code. Does this code require our mnemonic?

Hi,@ramchan. The code you are referring to is OK, but of course there are some preconditions:

  • you should use a local server and check that the port number is OK, or use a public service like PureStake, for example. I prefer to use Purestake, and changed the code to use Purestake
  • you should set up two accounts, and the passphrases should be inserted into the code
  • you should “fuel” your two accounts with Algorand initially.

With these changes, the code runs without any glitches.

To use PureStake API, use can get your token there, or use (for Testnet) the token THEY use in their examples:

const x_api_key = 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab'; 

const token = {
  "X-API-key": x_api_key,
};

const server = "https://testnet-algorand.api.purestake.io/ps2";
const port = "";

To set up the two accounts, you can use the command line interface, or create a wallet and two accounts using https://wallet.myalgo.com or https://www.a-wallet.net/

After the creation of the two accounts, you should get some Algos at Testnet dispenser, https://bank.testnet.algorand.network/

And, of course, you should substitute the 25-word passphrases of the two accounts to the example program, where it says: "Your 25-word mnemonic goes here"

I hope this helps.
Good luck!

1 Like

Hi @Maugli
Thanks for response
Actually, I am trying to create an NFT token using an algo network. I just created a simple website to create their NFT token by clicking create NFT button.
whenever a user clicks create NFT button. The wallet address connects to the contract.so I need to pass the wallet address connect to the contract function. How can we pass the wallet address instead of directly substitutes the mnemonics passphrases?

The NFT by definition is ASA which is issued in quantity 1. You can move this asset between the algo addresses thus owner of the NFT is the owner of the private key of the address it resides at.

Possible attributes while defining ASA:

Creator, manager, Reserve,Frozen and Clawback are algo addresses… It is better to have the mnomenic for these addresses when you create the asset… Reserve,Frozen and Clawback should be empty in my opinion for NFT

Hi @scholtz
Thanks for your response.
I created ASA using javascript. but it is possible to change the creator address or manager address?
if so how can I change?

Code:-

const algosdk = require(‘algosdk’);
var account1_mnemonic = “your mnemonic”;
var account2_mnemonic = “your mnemonic”;
var account3_mnemonic = “your mnemonic”;
var recoveredAccount1 = algosdk.mnemonicToSecretKey(account1_mnemonic);
var recoveredAccount2 = algosdk.mnemonicToSecretKey(account2_mnemonic);
var recoveredAccount3 = algosdk.mnemonicToSecretKey(account3_mnemonic);
console.log(recoveredAccount3.addr);
const baseServer = “https://testnet-algorand.api.purestake.io/p”;
const port = “”;
const token = {
‘X-API-key’ : ‘your purestake api’,}
let algodclient = new algosdk.Algodv2(token, baseServer, port);
// Function used to wait for a tx confirmation
const waitForConfirmation = async function (algodclient, txId) {
let response = await algodclient.status().do();
let lastround = response[“last-round”];
while (true) {
const pendingInfo = await algodclient.pendingTransactionInformation(txId).do();
if (pendingInfo[“confirmed-round”] !== null && pendingInfo[“confirmed-round”] > 0) {
//Got the completed Transaction
console.log("Transaction " + txId + " confirmed in round " + pendingInfo[“confirmed-round”]);
break;
}
lastround++;
await algodclient.statusAfterBlock(lastround).do();
}
};

// Function used to print created asset for account and assetid
const printCreatedAsset = async function (algodclient, account, assetid) {
// note: if you have an indexer instance available it is easier to just use this
// let accountInfo = await indexerClient.searchAccounts()
// .assetID(assetIndex).do();
// and in the loop below use this to extract the asset for a particular account
// accountInfo[‘accounts’][idx][account]);
let accountInfo = await algodclient.accountInformation(account).do();
for (let idx = 0; idx < accountInfo[‘created-assets’].length; idx++) {
let scrutinizedAsset = accountInfo[‘created-assets’][idx];
if (scrutinizedAsset[‘index’] === assetid) {
console.log("AssetID = " + scrutinizedAsset[‘index’]);
let myparms = JSON.stringify(scrutinizedAsset[‘params’], undefined, 2);
console.log("parms = " + myparms);
break;
}
}
};
// Function used to print asset holding for account and assetid
const printAssetHolding = async function (algodclient, account, assetid) {
// note: if you have an indexer instance available it is easier to just use this
// let accountInfo = await indexerClient.searchAccounts()
// .assetID(assetIndex).do();
// and in the loop below use this to extract the asset for a particular account
// accountInfo[‘accounts’][idx][account]);
let accountInfo = await algodclient.accountInformation(account).do();
for (let idx = 0; idx < accountInfo[‘assets’].length; idx++) {
let scrutinizedAsset = accountInfo[‘assets’][idx];
if (scrutinizedAsset[‘asset-id’] === assetid) {
let myassetholding = JSON.stringify(scrutinizedAsset, undefined, 2);
console.log("assetholdinginfo = " + myassetholding);
break;
}
}
};

(async () => {
// Asset Creation:
// The first transaciton is to create a new asset
// Get last round and suggested tx fee
// We use these to get the latest round and tx fees
// These parameters will be required before every
// Transaction
// We will account for changing transaction parameters
// before every transaction in this example
let params = await algodclient.getTransactionParams().do();
//comment out the next two lines to use suggested fee
params.fee = 1000;
params.flatFee = true;
console.log(params);
let note = undefined; // arbitrary data to be stored in the transaction; here, none is stored
// Asset creation specific parameters
// The following parameters are asset specific
// Throughout the example these will be re-used.
// We will also change the manager later in the example
let addr = recoveredAccount1.addr;
// Whether user accounts will need to be unfrozen before transacting
let defaultFrozen = false;
// integer number of decimals for asset unit calculation
let decimals = 0;
// total number of this asset available for circulation
let totalIssuance = 1000;
// Used to display asset units to user
let unitName = “asset symbol”;
// Friendly name of the asset
let assetName = “asset name”
// Optional string pointing to a URL relating to the asset
let assetURL = “http://someurl”;
// Optional hash commitment of some sort relating to the asset. 32 character length.
let assetMetadataHash = “16efaa3924a6fd9d3a4824799a4ac65d”;
// The following parameters are the only ones
// that can be changed, and they have to be changed
// by the current manager
// Specified address can change reserve, freeze, clawback, and manager
let manager = recoveredAccount2.addr;
// Specified address is considered the asset reserve
// (it has no special privileges, this is only informational)
let reserve = recoveredAccount2.addr;
// Specified address can freeze or unfreeze user asset holdings
let freeze = recoveredAccount2.addr;
// Specified address can revoke user asset holdings and send
// them to other addresses
let clawback = recoveredAccount2.addr;

// signing and sending "txn" allows "addr" to create an asset
let txn = algosdk.makeAssetCreateTxnWithSuggestedParams(addr, note,
     totalIssuance, decimals, defaultFrozen, manager, reserve, freeze,
    clawback, unitName, assetName, assetURL, assetMetadataHash, params);

let rawSignedTxn = txn.signTxn(recoveredAccount1.sk)
let tx = (await algodclient.sendRawTransaction(rawSignedTxn).do());
console.log("Transaction : " + tx.txId);
let assetID = null;
// wait for transaction to be confirmed
await waitForConfirmation(algodclient, tx.txId);
// Get the new asset's information from the creator account
let ptx = await algodclient.pendingTransactionInformation(tx.txId).do();
assetID = ptx["asset-index"];

// console.log("AssetID = " + assetID);

await printCreatedAsset(algodclient, recoveredAccount1.addr, assetID);
await printAssetHolding(algodclient, recoveredAccount1.addr, assetID);


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(recoveredAccount2.sk)
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);

Yes, it can be changed, see the following excerpts from the above code:

As explained by @Maugli the manager address, reserve address, freeze address, and clawback address can be changed by the manager as long as they’re not zeroed out.

The creator cannot be changed.

See Assets - Algorand Developer Portal for details.