xclud / web3dart

Ethereum library, written in Dart.
https://pub.dev/packages/web3dart
MIT License
170 stars 94 forks source link

sendTransaction gets invalid sender #51

Closed y0unghe closed 2 years ago

y0unghe commented 2 years ago

I am using web3dart on Mumbai polygon. I constructed a Web3Client client with a https://polygon-mumbai.infura.io/v3/ URL. The API key is not filled in, but it's there.

First I get the estimated gas, and it's working fine.

BigInt estimateGas = await client.estimateGas(
  to: to,
  sender: EthereumAddress.fromHex(address),
  value: EtherAmount.fromUnitAndValue(
      EtherUnit.ether, BigInt.from(amount)),
);

and then I try to send some MATIC to the some address. The RPCError returns the message: "invalid sender".

try {
  await client.sendTransaction(
      credentials,
      Transaction(
        to: to,
        from: credentials.address,
        value: EtherAmount.fromUnitAndValue(
            EtherUnit.ether, BigInt.from(amount)),
      ),
    );
} on RPCError catch (e) {
  final message = e.message;
}
chaoyang-zhou commented 1 year ago

兄弟解决了吗?我遇到同样的问题。

mmMrz commented 1 year ago

i got the error too