xclud / web3dart

Ethereum library, written in Dart.
https://pub.dev/packages/web3dart
MIT License
170 stars 94 forks source link

[Feature-Request] Web3 Provider Compatible with GSN (gasless transactions) #63

Open jpiabrantes opened 1 year ago

jpiabrantes commented 1 year ago

Allow Gasless Transactions The Ethereum GSN allows for gasless transactions. This gives users a very good UX because they don't need to go through KYC to buy ETH (or MATIC) to use your dapp and pay the gas fees. The way this works is that the user signs a meta-tx that is sent to a relayer and then gets executed by a smart contract that pays the gas fees (the dapp owner funds this smart contract).

Describe the solution you'd like Openzeppelin has a package @openzeppelin/network where the web3 provider can work with GSN:

const local = useWeb3Network('http://127.0.0.1:8545', {
  gsn: { signKey: useEphemeralKey() }
});

OpenGSN also has a package @opengsn/provider that gives a GSN compatible provider:

const { RelayProvider } = require('@opengsn/provider')

const config = { 
    paymasterAddress,
    loggerConfiguration: {
        logLevel: 'debug'
    }
}
const provider = await RelayProvider.newProvider({ provider: web3.currentProvider, config }).init()
const web3 = new Web3(provider);

To sum up, to get the best web3 UX I would love to have a web3dart provider compatible with GSN.