I'm trying to develop a mobile app in Flutter which should interact with a very simple contract.
The contract contains a basic string which can be read or write.
My environment is the following:
Ganache running on localhost, with the contract deployed at a know address.
A physical Android device with adb-reverse to reach the Ganache network.
On the Android I've Metamask app installed with the Ganache network set and one of the Ganache account.
The app has a login button, which redirect the user to Metamask for the login, and it initialise the session.
After that it displays a screen with a text containing the value of the contract variable, a textField and a button.
Tapping on the button should execute a transaction that updates the value on the contract with the textField content.
Problem
After looking around on Github for examples I was able to assemble the code and make it work.
The EthClient, the Connector and the Contract are initialised correctly.
At login button tap the user is switched to Metamask and a popup ask to connect to the mobile app.
After that the user can interact with the TextField and submit the new value.
I copied the WalletConnectEthereumCredentials from the example folder and here's my version:
When the user tap on the button, a transaction is sent.
Now if the user want to proceed he has to open manually Metamask and confirm the transaction through a popoup.
Is there a way to avoid having to move in Metamask and confirm every simple transaction every time, then switch back in the app?
I was able to automatically open Metamask every time a transaction is sent, with this code inside the sendTransaction:
Environment
I'm trying to develop a mobile app in Flutter which should interact with a very simple contract. The contract contains a basic string which can be read or write.
My environment is the following:
localhost
, with the contract deployed at a know address.adb-reverse
to reach the Ganache network.I'm using the following dependencies:
I use the Web3Dart code generator to generate the class to interact with my contract.
Expected behaviour
The app has a login button, which redirect the user to Metamask for the login, and it initialise the session. After that it displays a screen with a text containing the value of the contract variable, a textField and a button. Tapping on the button should execute a transaction that updates the value on the contract with the textField content.
Problem
After looking around on Github for examples I was able to assemble the code and make it work. The EthClient, the Connector and the Contract are initialised correctly. At login button tap the user is switched to Metamask and a popup ask to connect to the mobile app. After that the user can interact with the TextField and submit the new value.
I copied the
WalletConnectEthereumCredentials
from the example folder and here's my version:When the user tap on the button, a transaction is sent. Now if the user want to proceed he has to open manually Metamask and confirm the transaction through a popoup.
Is there a way to avoid having to move in Metamask and confirm every simple transaction every time, then switch back in the app?
I was able to automatically open Metamask every time a transaction is sent, with this code inside the
sendTransaction
:But still a confirmation for every transaction is needed.
Thanks