Describe the bug
I am Developing a application that can interact with a locally developed smart contract . The Connection and normal method contract calling works but I did not found any implementation for send transaction . In documentation it said to use the web3dart , but this requires private key to be stored in app . So I am trying this since 2 days now to just send the transaction using the session got from this plugin and tried many ways to do it but any of them did not work . Also looked at example app of this repo and tried to figure out, but is not working .Below are approches and their undesired outputs. I would really appreciate the response as soon as possible.
To Reproduce
Steps to reproduce the behavior:
- Run your own Smart Contract Locally and start node and deploy
- Setup web3modal_flutter as said in docs
- Try to call a method that is not just view and can also be payable
- See error or undesired behaviour
Expected behavior
Output should be transaction Id as it ,when done using web3dart . When done only using web3dart output is fine.But Real Wallet needs to be connected.
Screenshots/Codes and Outputs
function registerDeveloper(
bytes32 _name,
bytes32 _profile_photo_ipfs,
bytes32[] memory _techstack,
bytes32 _profession
)
public returns (bool ){...}
Approches:
using Just web3dart (which works):
return await _ethClient.sendTransaction(
_mCreds,
Transaction.callContract(
contract: _contract,
function: _registerDeveloper,
parameters: [
name.bytes32,
profilePhotoIpfs.bytes32,
techstack.map((e) => e.bytes32).toList(),
profession.bytes32
]),
chainId: 31337);
But when using wallet Credentials
to pass in method sendTransaction. According to this solution
A2:
var credentials = WalletConnectEthereumCredentials(
wcClient: dapp,
session: session,
);
final max = await _ethClient.estimateGas(
data: _registerDeveloper.encodeCall( [
name.bytes32,
profilePhotoIpfs.bytes32,
techstack.map((e) => e.bytes32).toList(),
profession.bytes32
])
);
debugPrint(max.toString());
var txn = Transaction.callContract(
contract: _contract,
function: _registerDeveloper,
maxGas: max.toInt(),
parameters: [
name.bytes32,
profilePhotoIpfs.bytes32,
techstack.map((e) => e.bytes32).toList(),
profession.bytes32
]);
var r = await _ethClient.sendTransaction(
credentials,
txn);
debugPrint(r);
return r;
A3:
using how it was called in example :
final Transaction t = Transaction.callContract( contract: _contract,
function: _registerDeveloper,
parameters: [
name.bytes32,
profilePhotoIpfs.bytes32,
techstack.map((e) => e.bytes32).toList(),
profession.bytes32
]);
debugPrint("---------------------------------------------------------------------------------");
var s = await EIP155.ethSendTransaction(
w3mService: _dapp,
topic: topic,
chainId: chainId,
transaction: EthereumTransaction(
from: from,
to: _contract.address.hex,
data: c.hex.encode(List<int>.from(t.data!))
, value: "0x"),
method: EIP155UIMethods.ethSendTransaction.name);
debugPrint(s);
return s;
The behaviour of above A2 & A3 is different the transaction is getting stuck , the control does not reach down to print s
even after some minutes . When Direct web3dart send-transaction takes 2-3 secs. In case of A2 the maxgas is printed but r
does not
Desktop (please complete the following information):
- OS: Windows 11
- Browser :chrome
- Version : Version 120.0.6099.217 (Official Build) (64-bit)
Smartphone (please complete the following information):(Emulator)
- Device: Pixel7Pro
- OS: Android
- SDK: API 34