Why is this not working?

I’m trying to set up GSN on the Ropsten network.

Problem:

Metamask asks me 2 times for my sign and shows this message.

Contract:

pragma solidity ^0.8.0;

import "./Initializable.sol";
import "./gsn/BaseRelayRecipient.sol";

contract TestRelayRecipient is BaseRelayRecipient
{
	uint public value;

	function setTrustedForwarder(address pForwarder)
		external
	{
		trustedForwarder = pForwarder;
	}
	function versionRecipient()
		external
		override view
		returns (string memory)
	{
		return "2.0.0";
	}

	function testCall()
		external
	{
		value++;
	}
}

Migrations (paymaster is set to accept everything paymaster):

  await deployer.deploy(Recipient);
  await deployer.deploy(Paymaster);

  let recipient = await Recipient.deployed();
  let paymaster = await Paymaster.deployed();

  let forwarderAddress = "0x25CEd1955423BA34332Ec1B60154967750a0297D";

  await recipient.setTrustedForwarder(forwarderAddress);
  paymaster.setRelayHub("0x29e41C2b329fF4921d8AC654CEc909a0B575df20");
  paymaster.setTrustedForwarder(forwarderAddress);

  console.log("recipient: " + recipient.address);
  console.log("forwarder: " + forwarderAddress);
  console.log("paymaster: " + paymaster.address);

My page:

const ethers = require('ethers')



const contractArtifact = require('../testContract.json')
const contractAddress = "0x3054d839001ec90e2Fe8C9C68Fe8D518a37C368E"
const contractAbi = contractArtifact.abi

const { RelayProvider } = require("@opengsn/gsn");

const paymasterAddress = "0x0e40fE8B24cD6475C5B741c43a0ea34cB6393A90";

let provider
let network
let acct;
let signer;
let account;

async function identifyNetwork () {
  const tmpProvider = await new ethers.providers.Web3Provider(window.ethereum)
  network = await tmpProvider.ready
  const gsnConfig = {
	  paymasterAddress: paymasterAddress,
	  loggerConfiguration: {
        logLevel: 'debug',
    }
  };
  
  const gsnProvider = await RelayProvider
  .newProvider({
	  provider: window.ethereum,
	  config: gsnConfig
  })
  .init();
  provider = new ethers.providers.Web3Provider(gsnProvider);
  acct = provider.provider.newAccount();
  signer = provider.getSigner(acct.address, acct.privateKey)
  account = (await ethereum.request({ method: 'eth_requestAccounts' }))[0];
  return network
}

async function contractCall () {
  await window.ethereum.enable()
  const contract = new ethers.Contract(
    contractAddress, contractAbi, provider.getSigner())
  const transaction = await contract.testCall()
  const hash = transaction.hash
  console.log(`Transaction ${hash} sent`)
  const receipt = await provider.waitForTransaction(hash)
  console.log(`Mined in block: ${receipt.blockNumber}`)
  
  
}

let logview
function log(message) {
    message = message.replace( /(0x\w\w\w\w)\w*(\w\w\w\w)\b/g, '<b>$1...$2</b>')
    if ( !logview) {
        logview = document.getElementById('logview')
    }
    logview.innerHTML = message+"<br>\n"+logview.innerHTML
}
async function load () {
  const contract = new ethers.Contract(
    contractAddress, contractAbi, provider);
	
	document.getElementById('value').innerHTML = await contract.value();

window.app = {
  contractCall,
  load,
  log,
  identifyNetwork
}

Did you fund your paymaster?
after creating it (and setting forwarder, relayhub) you must send some eth to it, so it will be able to pay for your transactions.
(note that this ETH is saved as a “deposit” in the RelayHub, so you will not see it as normal eth balance.
The paymaster can call “withdraw” any time to get it back if it doesn’t want to serve clients anymore.)

Yes, before starting I ran:

tmpProvider.getSigner().sendTransaction({to: paymasterAddress, value: ethers.utils.parseEther(“0.1”)})

but this doesn’t solve anything.

However! If I change the whole code and set paymaster address to 0x8057c0fb7089BB646f824fF4A4f5a18A8d978ecC from
https://docs.opengsn.org/contracts/addresses.html#ethereum

it works. So the problem must be with the paymaster. What is wrong with him?

make sure you have called paymaster.setForwarder
it must be the same as the one you’re using in your contract.

Look at the “Migrations” part. There is a call to setTrustedForwarder both in paymaster and recipient.

Your balance might be too low: paymaster must be able to pay for “max possible charge”, which is calculated based on blockGasLimit.
Try moving more funds to it.

Charged with 0.1 eth, same error. Charged with 1 eth, same error. Ropsten network.

I’m using this paymaster:

this is a version 2.2.0 (unreleased yet) paymaster, which is incompatible with the 2.0.0 contracts already deployed.
please use the “release” branch as a base (or the one from the @opengsn/gsn package)
e.g. add to your project:
import “@opengsn/gsn/contracts/test/TestPaymasterEverythingAccepted.sol”