ERC20, transferFrom() not working with non-owner accounts

I have the simplest boilerplate of EC20 contracts, MYToken (see below), with a 1000 token total supply.

I ompiled and migrated in Truffle as shown below in CLI steps.
I am working in Truffle Console, local dev environment, as denoted with ‘>’
Environment is:
Truffle v5.4.26 (core: 5.4.26)
Solidity - ^0.8.0 (solc-js)
Node v16.13.0
Web3.js v1.5.3

CLI Steps

truffle compile
truffle migrate development
truffle console development

>let accounts = await web3.eth.getAccounts()
>instance = await MYToken.deployed()
>instance.totalSupply() << returns 1000
>instance.balanceOf(accounts[0]) << returns 1000
>instance.approve(accounts[0], 500) << so I can send some to accounts[1]
>instance.transferFrom(accounts[0], accounts[1], 50) << sends 50 to acct[1]
>instance.balanceOf(accounts[0]) << returns 950
>instance.balanceOf(accounts[1]) << returns 50

Now, my question: I cannot figure out how to send tokens from accounts[1] to accounts[2] ?

What I really want is to execute this:

>instance.approve(accounts[1], 50)
>instance.transferFrom(accounts[1], accounts[2], 10)

I’ve trialed and errored a number of commands using .allowance() as well, etc, with a variety of errors including the expected “ERC20: transfer amount exceeds allowance”

I think I just don’t yet understand the concepts of allowance and approve.

Any guidance would be appreciated. TIA

// contracts/METoken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract METoken is ERC20 {
    constructor() ERC20("My Ethereum Token", "MET") {
        _mint(msg.sender, 1000);
    }
}

Hi,

For the transfer to be succesful, just approve the tokens to be transfered from the right account to the right account, prior to executing the transferFrom call.

The reason you are getting the “ERC20: transfer amount exceeds allowance” when transferring from account[1] to account[2] is because when you call the approve method the sender should be the account that is going to grant the allowance to the account sent as parameter.

Following the code you used:

instance.approve(accounts[1], 50)
instance.transferFrom(accounts[1], accounts[2], 10)

On the first command you are running the approve method with the account[0] as the sender, therefore if you try to transferFrom account[1] to account[2] the only allowance saved on the contract was 50 tokens from account[0] to account[1]. But there is none from account[1] or granted to account[2].
.

Thanks, @JulissaDantes, and HNY.
Your answer pointed me in the correct direction.
instance.transferFrom(), though fails
instance.transfer(), succeeds

This is what worked.

web3.eth.defaultAccount = accounts[1] <<< The key which unlocked my door
instance.approve(accounts[1], 50)
instance.transferFrom(accounts[1], accounts[2], 10) <<< failed 'ERC20: ...exceeds...'
instance.transfer(accounts[2], 10) <<< transfer() <<< succeeded

Thanks again.