Encountering a " Warning: Couldn't broadcast tx with algod: HTTP 400 Bad Request: transaction "error when attempting to send a transaction using `goal clerk rawsend`

Your original post says you’re using your old address in all three fields, but it should be:

Sender = account1 (has auth)
Receiver = account1 (has auth)
Rekey = account2 (new address to be given auth AKA your old address)

Docs:

  • Sender: This is the address of the account that you want to rekey. This account must have enough balance to pay for the transaction fee.

  • Receiver: This is typically set to the sender’s address. This is because the purpose of the transaction is not to transfer funds, but to change the spending key of the sender’s account.

  • Rekey-to: This is the address that you want to change the spending key to. After the transaction is confirmed, this address’s private key will be the new spending key for the sender’s account.

const rekeyTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
 from: acct1.addr,
 to: acct1.addr,
 amount: 0,
 suggestedParams,
 rekeyTo: acct2.addr, // set the rekeyTo field to the new signer
});