Request to a relayer from web3

Having tried working with GSN locally (using Ganache), i tried to implement same thing via infura but i’m having an issue.

When working locally, i used something like Contract.methods.myMethod().send({}).
When using Infura i cannot use that because Infura requries it to be signed, how do i send the transaction to the relayer? Do i need to signAndSend?

1 Like

Hi @sirphemmiey,

I recommend going through the Building a GSN powered (d)app from scratch guide and get the dapp running on a testnet. I found this really helpful.

We don’t need to change Contract.methods.function().send({}) for the GSN.
We can configure the web3 context to use the GSN. See the following from the above guide:

import { useWeb3Network, useEphemeralKey } from "@openzeppelin/network/react";

// inside App.js#App()
const context = useWeb3Network('https://rinkeby.infura.io/v3/' + INFURA_API_TOKEN, {
  gsn: { signKey: useEphemeralKey() }
});

I thought that was for React, am i wrong?

I am currently using it through Node.js

1 Like

Hi @sirphemmiey,

You can use OpenZeppelin Network.js with Vanilla Javascript.

You could use the following in Vanilla JavaScript:

const web3context= await fromConnection('http://127.0.0.1:8545', { 
  gsn: { signKey: ephemeral() } 
});

A post was split to a new topic: How to determine error from relayed call