I am using web3dart to send transaction.
I already connect wallet for polygon but can't sign transaction.
I think it's due to credential problem.
@override
Future<String?> sendAmount({
required String recipientAddress,
required double amount,
}) async {
final sender =
EthereumAddress.fromHex(_connector.connector.session.accounts[0]);
// final recipient = EthereumAddress.fromHex(address);
final recipient = EthereumAddress.fromHex(recipientAddress);
final etherAmount =
EtherAmount.fromUnitAndValue(EtherUnit.szabo, (amount).toInt());
final transaction = Transaction(
to: recipient,
from: sender,
gasPrice: EtherAmount.inWei(BigInt.one),
maxGas: 100000,
value: etherAmount,
);
final credentials = WalletConnectEthereumCredentials(provider: _provider);
// Sign the transaction
try {
final txBytes = await _polygon.sendTransaction(credentials, transaction);
return txBytes;
} catch (e) {
print('Error: $e');
}
return null;
}
This code works on ethereum network but not in polygon.