Gas Station Network without React (using infura.io)

Hi. I tried and Gas Station Network Example works well. (sdk/2.5/gsn-dapp)
But I want to same thing without React.

For that I tried to use GSNProvider ( OpenZeppelin/openzeppelin-gsn-provider )
but When I made transaction , I had error "The method eth_sendTransaction does not exist is not available"
I understand that infura.io doesn't allow it.

Can I have another way to use Gas Station Network witout Ract and using infura.io?

const provider = new GSNDevProvider("infura-io-address", {
signKey: xxxx,
ownerAddress: xxxx,
relayerAddress: xxxx,
verbose: true
})
const web3 = new Web3(provider);
contract = new web3.eth.Contract(abi, address)
const tx = await contract.methods.mint().send({
from: xxxx
});

1 Like

Hi @oggata,

Welcome to the community :wave:

If you are using Vanilla JavaScript (or a framework other than React) you can still use OpenZeppelin Network.js. Have a look at the README section to Use with Vanilla JavaScript:

1 Like

Hi @abcoathup
Thanks!! I solved it !!!!!!!
I want to use Gas Station Network in my game application. Very thanks for your help!!

const { fromInjected, fromConnection } = require('@openzeppelin/network');
const injected = await fromConnection('infura-io-url', {
gsn: { signKey: "xxx" }
});
const instance = new injected.lib.eth.Contract(abi, address);
const tx = await instance.methods.mint().send({
from: address
});
console.log(tx);

1 Like

Hi @oggata,

Glad to hear! :smile:

I created a PR to improve the README: https://github.com/OpenZeppelin/openzeppelin-network.js/pull/18

You could call your injected variable something like web3Context as it is from a connection rather than injected.

If you want to share information about your game you are developing in #general:showcase (along with how you are using OpenZeppelin) that would be great.

Hi @abcoathup
Thanks to improve the README !!

Gas Station Network is very usefull and amazing.
I want to show my product on general/showcase in a few weeks.

Thanks for your help!!!

1 Like