Не удается отправить транзакцию в полигональной сети с помощью флаттера
Я использую web3dart для отправки транзакции.
Я уже подключаю кошелек для полигона, но не могу подписать транзакцию.
Я думаю, это из-за проблемы с учетными данными.
@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;
}
Этот код работает в сети ethereum, но не в полигоне.