Closed Hathoriel closed 1 year ago
@Hathoriel you can pass the following optional parameters to the function and it should work!
await client.sendTransaction(
credentials,
Transaction.callContract(
contract: contract,
function: transferFunction,
parameters: [params]),
fetchChainIdFromNetworkId: true, chainId: null);
Hi, thanks for info. I will try it. 👍
Dne so 17. 12. 2022 20:32 uživatel Jaafar Rammal @.***> napsal:
@Hathoriel https://github.com/Hathoriel you can pass the following optional parameters to the function and it should work!
await client.sendTransaction( credentials, Transaction.callContract( contract: contract, function: transferFunction, parameters: [params]), fetchChainIdFromNetworkId: true, chainId: null);
— Reply to this email directly, view it on GitHub https://github.com/xclud/web3dart/issues/80#issuecomment-1356404813, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACTBOBNFREODWWAG2WED5L3WNYIN5ANCNFSM6AAAAAATAD6YRU . You are receiving this because you were mentioned.Message ID: @.***>
Hi I finally made it working with this code:
sendNativeTransaction(String to, String amount, String walletId, String password) async {
final client = _getEthClient();
final credentials = await getPrivateKeyEthKey(password, walletId);
final toAddress = Web3Dart.EthereumAddress.fromHex(to);
final amountWei = double.parse(amount) * 1000000000;
print(BigInt.from(amountWei.toInt()));
final amountToSend = Web3Dart.EtherAmount.fromUnitAndValue(Web3Dart.EtherUnit.gwei, BigInt.from(amountWei.toInt()));
final transaction = Web3Dart.Transaction(
to: toAddress,
value: amountToSend,
maxGas: 21000,
gasPrice: Web3Dart.EtherAmount.inWei(BigInt.from(1500000000)),
);
print(transaction.toString());
final response = await client.sendTransaction(credentials, transaction, fetchChainIdFromNetworkId: true, chainId: null);
print(response);
return response;
}
Main thing which made it working was this part:
fetchChainIdFromNetworkId: true, chainId: null
Would it make sense to add this inside readme, because as it is right now it didn't worked? https://pub.dev/packages/web3dart
This helped. @Hathoriel can you close this issue since the solution has been addressed and tested above.
Closed ❤️
Hi, I cannot send a transaction, it returns me "invalid sender" error. I am adding the following screenshot