Metamask: sending multiple transactions, without prompting user each time

Viewed 706

Say, I have an interactive dapp, like a game and I want the user's actions to be saved on the blockchain (maybe these are moves in the game of chess, whatever).

So, from my understanding, options are:

  • Create dynamic wallet via web3, prefill it from the metamask and send as many transactions as I want.
  • Somehow negotiate with the user to trust the dapp and let metamask send transactions on user's behalf without pesky prompting.

What is the right option (if any)? Turns out, metamask has a whole permission escalation framework, yet I wasnt able to ask the right permission.

1 Answers

You can access user funds in several ways:

  1. ask users to deposit in a smart contract and keep track of balances there
  2. ask users to allow your smart contract to spend their tokens via ERC20 allowance

How often will user actions be saved on the blockchain?

Even if your dapp has access to all user funds via a shared wallet or ERC20 allow() + transferFrom() you'll still need somebody to trigger a transaction and pay gas fees whenever you're updating chain state.

Related