Calling transfer method on erc20 token contract using opengsn

I am trying to send erc20 token using the transfer method from an account which does not have ether but has the erc20token using gsn but I am getting an error failed to sign relayed transaction how should I sign the transaction
here is my code

const Web3 = require("web3");
const web3 = new Web3(``);
const accountinfo = require("./accountcreation");
const GSN =require("@opengsn/gsn")
const {resolveConfigurationGSN} = require("@opengsn/gsn/dist/src/relayclient/GSNConfigurator");

//const Tx = require("ethereumjs-tx").Transaction;

const contractabi = require("./GLDToken.json");

const contract = new web3.eth.Contract(
  { from: "0xd275533c74bd3772166623fefd8127a6805a71c4" }
let paymasterAddress = "0x30A56e9f9E04d3E31Ee6571db1153F05fB26B038"
let forwarder = "0x646fDd5F4d5b25D8012d62f4A038F0EFd963c600"

async function transferwithGSN(indexfrom,indexto,amount){
  const config = await  resolveConfigurationGSN(web3.currentProvider,{paymasterAddress,forwarder,verbose:true})
  let provider = new GSN.RelayProvider(web3.currentProvider,config);
  let fromaddress =accountinfo.accountdetails(indexfrom);
  let from =(await fromaddress).address[0].toString();
  let fromPrivateKey = Buffer.from((await fromaddress).privateKey,"hex");
  let receiver = accountinfo.accountdetails(indexto)
  let to =(await receiver).address[0].toString();
  let amounttosend = await web3.utils.toWei(amount.toString(), "kwei");

  let count = await web3.eth.getTransactionCount(from);
  console.log('FROM:',from,'TO:',to,'AMOUNT TO SEND:',amounttosend,'TRANSACTION COUNT:',count)

  let contractaddress = contractabi.networks["1337"].address;


  const gldtoken= new web3.eth.Contract(contractabi.abi,contractaddress);
  const receipt =await gldtoken.methods.transfer(to,amounttosend).send({from,gas:1e6});


My contract

// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.10;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@opengsn/gsn/contracts/BaseRelayRecipient.sol";
import "@opengsn/gsn/contracts/interfaces/IKnowForwarderAddress.sol";

contract GLDToken is ERC20,BaseRelayRecipient,IKnowForwarderAddress {
    constructor(uint256 initialSupply,address _forwarder) public ERC20("Gold", "GLD") {
        _mint(_msgSender(), initialSupply);

    function _msgSender() internal override(Context, BaseRelayRecipient)
    view returns (address payable) {
        return BaseRelayRecipient._msgSender();

    function _msgData() internal override(Context,BaseRelayRecipient)
    view returns (bytes memory ret) {
        return BaseRelayRecipient._msgData();

    string public override versionRecipient = "2.0.0";

    function getTrustedForwarder() public view override returns(address) {
    return trustedForwarder;

  1. “verbose:true” was changed to ‘logLevel:“debug”’
  2. do you have that many accounts? by default, ganache starts 10 accounts, and you’re using the 12th account…
  3. I don’t know what’s this “account info”. I usually use (await web3.eth.getAccounts())[0] this uses one of ganache’s pre-provisioned accounts (which already have eth, though GSN will not use it)
  4. if you want to create a new account, you can use from = gsnProvider.newAccount().address (or await web3.eth.personal.newAccount('password')

I am using the 12th account since all the other ten had ether and I wanted to test out using gsn.
Account info is a file I use with truffle HD wallet with a mnemonic to generate accounts. Is it possible to add another account to the gsn provider if I have its private key?

const HDWallet = require("@truffle/hdwallet-provider");

async function accountdetails(accountindex) {
  let wallet = new HDWallet({
    providerOrUrl: "",
    addressIndex: accountindex,
    numberOfAddresses: 1,

  let address = await wallet.addresses;

  let privateKey = wallet.wallets[address]._privKey.toString("hex");
  let publicKey = wallet.wallets[address]._pubKey.toString("hex");
    return {
    address: address,
    privateKey: privateKey,
    publicKey: publicKey,


module.exports = { accountdetails };

AFAIK, you can’t use accounts more than are defined in ganache, since its an array, so accounts[11] is undefined.
You can add accounts using gsnProvider.newAccount(), or if you have explicit privateKey/address you want to use, then call gsnProvider.addAccount( {privateKey,address} )
Just notice that priateKey has to be Buffer (e.g if you have a hex string, set it to Buffer.from(hexPrivKey.replace(/0x/,''), 'hex') )