[SOLVED] How to use .send() on a solidity function call from within Web3.js

So I have a conundrum. In order for me to get the user to sign a transaction web3.eth.accounts.signTransaction() wants the private key as input. I want metamask/the wallet to handle all this and never want to handle the private key if I can possibly avoid it (I don’t even like the idea of having it in memory)

Here is some code

const handleSubmit = (e) => {
      e.preventDefault()
      const transfer =aetokenContract.methods.safeTransferFrom(sendFrom, sendTo, "0", sendAmount, [])
      const encodedABI = transfer.encodeABI()
      const tx = {
          from: "sendFrom",
          to: sendTo,
          gas: 2000000,
          data: encodedABI
      };

      web3.eth.accounts.signTransaction(tx, "It wants the private key here").then(signed => {
          var tran = web3.eth.sendSignedTransaction(signed.rawTransaction);

          tran.on('confirmation', (confirmationNumber, receipt) => {
              console.log('confirmation: ' + confirmationNumber);
          });

          tran.on('transactionHash', hash => {
              console.log('hash');
              console.log(hash);
          });

          tran.on('receipt', receipt => {
              console.log('reciept');
              console.log(receipt);
          });

          tran.on('error', console.error);
      });
  }

aetokenContract.methods.safeTransferFrom(sendFrom, sendTo, "0", sendAmount, []).send({from: sendFrom}) wouldn’t do automatically what you want to do here?

Nope, it probably will. It stems from a misunderstanding. Give me a moment to try.

Yep, works fine. I was trying


.send(sendFrom)

not

.send({from: sendFrom})

And then I follow a different tutorial that was not all that relevant, this was a poorly framed question and a good solution non the less.