ERC20 : problem with transferFrom


I am trying to make a staking application DApp and I am facing this problem when I launch the DApp:

Obviously, it's a problem of balance, this one is not enough big. I red this link too:

In my SC of staking, I use this function to stake:

Everything works fine in Remix.

I don't understand very well how to set the balance to be greater than the transfer amount. Can I do this in the UI, in the 2_deploy_contracts.js?

This is my 2_deploy_contracts.js:

I set the initialStakeCoinSupply in SC token too:

contract StakeCoin is ERC20, Ownable {

    uint256 public initialStakeCoinSupply = 1000000000000000000000000;

        @notice the constructor for the Staking coin token
        @dev the owner is the admin of the interface
        @param initialStakeCoinSupply The amount of initial tokens to mint on construction
        <!> it works with Remix!
    constructor(uint initialStakeCoinSupply) ERC20("Stake Coin Token", "STC") {
        _mint(owner(), initialStakeCoinSupply);

     *   @notice produces some tokens for a smart contract
     *   @param to address of the recipient
     *   @param value amount of tokens to produce
     *   @return boolean did we produce some tokens?
     *  <!> it works with Remix!
    function mint(address to, uint256 value) public onlyOwner returns (bool) {
        _mint(to, value);
        return true;

If you have a piece of advice to give me, don't hesitate please,

You can simply transfer tokens to the wallet that made the stake call. Nothing fancy.

Hello maxareo. To be sure, do you want to say - transfer my Stake coin tokens to the msg.sender who clicks on the button "deposit"?

Yes, because only who clicks on the button would stake, right?

yes, and I suppose that this transfer (because I will use -- Transfer -- function from open zeppelin ERC20) would be before the "approve" (l. 247) of my createStake function, can you confirm that?

transfer is to transfer the tokens you own to a target address whereas transferFrom is usually to transfer the tokens you don't own but are allowed to move on owner's behalf.

In your example, you first transfer tokens to the staker first so that he has tokens to stake and then he approves the contract to move his tokens on his behalf.