GSNProvider : getting error

I modified my Dapp web provider setup to access a Relayer via a running RelayHub on ganache dev chain (I deployed these using the gsn-helpers)

:computer: Environment
I am using a Truffle /Vue stack set up to work with injected Metamask OR a ganache dev chain running on a ssh vps IP: port -->

What I’m trying to do is allow Metamask if present; otherwise use GSN and have user contract calls go through the relayer. Here is my web3 setup:

if (window.ethereum) {
    web3Provider = window.ethereum
    try {
        await window.ethereum.enable()
    } catch (error) {
        console.error('User denied account access')
} else if (window.web3) {
    web3Provider = window.web3.currentProvider
// If no injected web3 instance is detected, fall back to Ganache
else {

    web3Provider = new GSNProvider("");
const web3 = new Web3(web3Provider)


I get a browser error in console (truncated for brevity): My error may be related to dependencies webpack or other issues with GSN, any help here would be appreciated:

SyntaxError: invalid property id
1 Like

Hi @Steeve,

Welcome to the community :wave:

You could look at using OpenZeppelin Network.js to simplify the web3 setup.

Though I suspect that there may be an issue running on your setup given the GSN Starter Kit compilation problems that you are experiencing. Might be best to resolve this first.

You could also look at the Building a GSN powered (d)app from scratch tutorial, though this is React based.

Indeed ,thanks, using oz-network.js is my preferred option. I replaced web3 with /openzeppelin-network.js. I used the vanilla setup in my Vue app which compiles but I get a Type Error in my browser web console:

TypeError: Object(…).version is undefined

A clue (?) is that I get a scrypt error when I check oz version. telling me something isn’t correctly versioned:

#oz --version
Error: The module β€˜/root/node_modules/scrypt/build/Release/scrypt.node’
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).

Again knowing which versions node I can run for OZ would help a lot and avoid breaking changes.

My setup is:

#node --version

#npm --version

1 Like

I fixed the scrypt node version mismatch by recompiling as noted on the scrypt github page. So now I get my oz --version 2.5.3
correctly for my Node version v11.6.0 without the warning.

But on serving the page my web browser console I get the same error;

TypeError: Object(…).version is undefined

1 Like

Hi @Steeve,

I currently use:

$ node --version
$ npm --version
$ oz --version

Do you have a GitHub repository that you can share?

It’s a Vue template I want to modify to run GSN . My first attempt was to use OZ network.js then I tried with GSN-provider. Somehow the β€˜resolve’ files that are present in the react Starter template may be what Im missing.

See the modified repo here. [edit]

The web3 connection is found in the ./src/components/SimpleStorage.vue
Vue is very similar to react with javascript between tags in components and the entry file is main.js

[Edit: btw i did redo the whole with node version 10.16]

1 Like

Hi @Steeve,

The SimpleStorage contract also needs the following functions:

  function _preRelayedCall(bytes memory context) internal returns (bytes32) {

  function _postRelayedCall(bytes memory context, bool, uint256 actualCharge, bytes32) internal {

I suggest looking at the Building a GSN powered (d)app from scratch tutorial, though this is React based.

I haven’t done any Vue development (or much React) to go digging around unfortunately.

Thanks, yes I will add the sol functions in the contract.
In the meantime I got it working by simply adding the all the OZ dependencies found in the Starter Kit. And with a relayer already running in my ganache blockchain , the Vue Dapp works without any modification to the web3 connection logic!
In my package.json, I added the following:

β€œdependencies”: {
β€œ@openzeppelin/contracts-ethereum-package”: β€œ^2.4.0”,
β€œ@openzeppelin/gsn-provider”: β€œ^0.1.6”,
β€œ@openzeppelin/network”: β€œ^0.2.9”,
β€œ@openzeppelin/solidity-loader”: β€œ^1.4.6”,
β€œ@openzeppelin/upgrades”: β€œ^2.5.3”,
β€œvue”: β€œ^2.5.13”,
β€œvue-router”: β€œ^3.0.1”,
β€œvuex”: β€œ^3.0.1”,
β€œweb3”: β€œ0.20.2”
β€œdevDependencies”: {
β€œ@openzeppelin/cli”: β€œ^2.5.3”,
β€œ@openzeppelin/contracts”: β€œ^2.4.0”,
β€œ@openzeppelin/gsn-helpers”: β€œ^0.1.9”,
β€œ@openzeppelin-test-helpers”: β€œ^0.4.3”,`

I had to β€˜force’ web3 to version0.20.2 since the web3 v1.x breaks this particular dapp.
Im still not clear on the role of GSN-Provider vs Network.js;
I’m way more familiar with Vue than React despite the similarities.