Open lrettig opened 6 years ago
As mentioned I think you need to supply usable account addresses present in aleth to Truffle. Or it may require the personal
API.
I did specify an account present in aleth to Truffle. The from
of the transaction is valid. If you look at the trace you'll see that account listed.
What's the personal
API?
I think it is an accounts issue. Despite the account in question existing and having a nonzero balance (from the genesis config), aleth doesn't recognize it:
> curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":14}' http://127.0.0.1:8545
{"id":14,"jsonrpc":"2.0","result":[]}
I also tried using:
I get the same "Unknown account" error regardless of which account I use.
it might be best to forget about eth_sendTransaction and hack truffle to use eth_sendRawTransaction. then you can do all the tx signing on the js side.
Also, what do you mean by "The genesis account"? If you want to use eth_sendTransaction, cpp needs to know the private key for whatever account you are trying to send from. Have you added the private key to cpp somehow?
I was able to work around this by using geth
to create a keystore file containing the required private key, then manually copying that into the keystore
directory beneath the database directory I'm running aleth
in (with the -d
flag). Oh, and the first time you send a tx from the account in question, aleth prompts you for the password for the keystore file (even if there is none) -- good luck catching that when running in full verbosity through a tee'ed logfile. So that RPC call will fail, but if you enter the password and hit enter, then the next one should succeed. 🤦♂️
I'm also encountering a ton of other errors trying to get truffle to talk to aleth -- bad nonce, random RPC errors. If I keep trying to deploy enough times, it seems to eventually sort itself out and start working. Anyway, the issue outlined in this issue seems to be resolved so I'll close this.
I do not call it a resolution if geth needs to create files and random password is prompted for :)
At least create issues for those and/or keep this umbrella one open.
Here's a braindump of the issues I see:
aleth
does not appear to contain a toolchain for adequately managing keystore files. alethkey
/ethkey
does some things but it does not seem able to take a simple private key (in hex) and generate a keystore file/add the key to a keystore. (That's the part I had to use geth
for.)aleth -s
, -S
, --master
and --password
didn't seem to work for me. It's not clear to me from the documentation what they're supposed to do, but they did not allow me to import a private key or keyfile either.aleth
prompting for a password the first time it encounters an account is an issue -- it should be possible to unlock that account using a commandline flag of some sort -- or if there is no password, there should be no prompt.truffle deploy
or truffle test
two or three times and sometimes it only worked the third time. Would require more investigation.aleth does not appear to contain a toolchain for adequately managing keystore files. alethkey/ethkey does some things but it does not seem able to take a simple private key (in hex) and generate a keystore file/add the key to a keystore.
Did you try aleth-key importbare <private_key_hex>
?
aleth -s <private_key_hex>
works for me, too, just doesn't report its success, imports the key silently.
aleth --unsafe-transactions
turns off initial prompt on account first access
--password
is supposed to give a password to try before asking the user, but it doesn't work for me, at least not for the imported accounts (I suspect it does only for keys create by aleth).
We should fix this.
If I run truffle using a basic, out-of-the-box solidity contract (
truffle unbox metacoin
) and then attempt to deploy/test against a localaleth
instance (withjsonrpcproxy
), I get a bunch of RPC errors:Full trace is at https://gist.githubusercontent.com/lrettig/63d7e941946a313ec460c6484cecfc82/raw/21f776da70f7a9d389c811abfed6b18258c5a55b/cpp-log.txt