How can I test ERC20 token using GSN on local test network?

how can I test my code?
If I try to send tokens through metamasks it’s still charging me ETH.

1 Like

Hi @medma05,

You can write automated smart contract tests that uses a local blockchain (see: Writing Automated Smart Contract Tests in the Learn guides).

You can also deploy to a public testnet and use testnet Ether which you can obtain from a faucet: (see: Connecting to Public Test Networks in the Learn guides). You can then test your contract manually.

A great reference on testing is: Test smart contracts like a rockstar

but not in this way, I already wrote unit tests for it. I’m trying to transfer tokens to but I insufficient funds on metamasks.

Even though, I added the GSNRecipient.

1 Like

Hi @medma05,

If users send tokens using MetaMask directly, this won’t be via the GSN.
You will need to create a DApp that requests relayed calls via the GSN and then add funds to your recipient so that it can pay for GSN transactions.

If you haven’t already, I suggest going through the Building a GSN-powered DApp guide.

Assuming you are just getting started, depending on your development roadmap, GSNv2 is under development at You may want to look at the upcoming improvements.

You can still use GSNv1, though you may want to run your own relayer in production. See Doubling down on security for more details.

I see, yes with a dapp is possible but what I want to do is to transfer my own ERC20 token to different accounts paying with the gas fee with the same token, an equivalent to how much it would be in wei. Similar to how an estable coin works, for example USDT.

1 Like

Hi @medma05,

Your dapp pays the transaction fees in Ether and you can implement a strategy to decide whether to accept relayed calls as part of the GSN.

An example strategy charges the user in an internal token (see: GSNRecipientERC20Fee).

You could create your own strategy that charges users for the transaction in your token. (see: Custom Strategies)

I suggest also joining the OpenGSN telegram to get the latest news on when GSNv2 will be on mainnet in case that is an option for you.