Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

invalid sender when sending a transaction using prepareforpaymentcall #15

Closed
DrasiusMajere opened this issue Nov 18, 2018 · 8 comments · Fixed by #16
Closed

invalid sender when sending a transaction using prepareforpaymentcall #15

DrasiusMajere opened this issue Nov 18, 2018 · 8 comments · Fixed by #16

Comments

@DrasiusMajere
Copy link

I'm using a solidity contract version 0.5.0 and infura for sending transactions. The function is not payable
for this reason I'm using EtherAmount.zero() parameter

E/flutter (16270): RPCError: got code -32000 with msg "invalid sender".
E/flutter (16270): #0 JsonRPC.call (package:web3dart/src/io/jsonrpc.dart:47:4)
E/flutter (16270):
E/flutter (16270): #1 Web3Client._makeRPCCall (package:web3dart/src/web3client.dart:29:30)
E/flutter (16270):
E/flutter (16270): #2 Web3Client.sendRawTransaction (package:web3dart/src/web3client.dart:177:10)
E/flutter (16270): #3 FinalizedTransaction.send. (package:web3dart/src/transaction.dart:112:18)

@maxholman
Copy link
Contributor

@DrasiusMajere Are you using ropsten?

I just submitted PR #16 that will allow you to specify a chainId for transactions. I was getting this same error using infura/ropsten.

@DrasiusMajere
Copy link
Author

Yes, I'm testing and obviously using ropsten....
Thank you for the support because I'm a newbie in ethereum
But I hope this package will be updated to the solidity 0.5.0

@maxholman
Copy link
Contributor

The PR will allow you to specify a chainId like this, that should solve the invalid sender error.

transaction.prepareForSimpleTransaction(
  new EthereumAddress("0x[...]"), // your target address 
  EtherAmount.fromUnitAndValue(EtherUnit.finney, 300)
).send(ethClient, chainId: 3);

@DrasiusMajere
Copy link
Author

It's working.
Now to send a transaction that calls a function that alters state variables is possible.

@ishwarchandratiwari
Copy link

The PR will allow you to specify a chainId like this, that should solve the invalid sender error.

transaction.prepareForSimpleTransaction(
  new EthereumAddress("0x[...]"), // your target address 
  EtherAmount.fromUnitAndValue(EtherUnit.finney, 300)
).send(ethClient, chainId: 3);

i had a same issue invalid sender when sending a transaction,
your snippet worked, but how can i get Transaction id ?

@DrasiusMajere
Copy link
Author

DrasiusMajere commented Mar 31, 2019

Actually send method return the transaction Id as a list of bytes, if you want an hexadecimal id more readable. I found a function that uses web3dart called bytesToHex.
var tranId = bytestoHex(await transaction.prepareForSimpleTransaction( new EthereumAddress("0x[...]"), // your target address EtherAmount.fromUnitAndValue(EtherUnit.finney, 300) ).send(ethClient, chainId: 3));

Maybe it would be recommended divide the code above in smaller parts.

@ishwarchandratiwari
Copy link

Actually send method return the transaction Id as a list of bytes, if you want an hexadecimal id more readable. I found a function that uses web3dart called bytesToHex.
var tranId = bytestoHex(await transaction.prepareForSimpleTransaction( new EthereumAddress("0x[...]"), // your target address EtherAmount.fromUnitAndValue(EtherUnit.finney, 300) ).send(ethClient, chainId: 3));

Maybe it would be recommended divide the code above in smaller parts.

i am getting error
The method 'bytestoHex' isn't defined for the class 'main'.

@DrasiusMajere
Copy link
Author

import 'package:web3dart/conversions.dart';

What IDE are you using? because you can leave the IDE looks for the appropriate library that contains that function and add the import statements automatically.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants