Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a default account in client #60

Closed
ghivert opened this issue Mar 1, 2018 · 6 comments
Closed

Setting a default account in client #60

ghivert opened this issue Mar 1, 2018 · 6 comments

Comments

@ghivert
Copy link

ghivert commented Mar 1, 2018

Hi EthWorks!

The package works really great, but I had a little problem with the default_account in the client. It is the main sender for every transaction (which is great), but it's impossible to set it to the desired value. For example, when using Infura, eth_accounts returns an empty array. The default_account is always nil, which complicates things as from: nil when sending transactions creates bugs.

Is it possible to have a version where we can access and modify the default_account?

@jasonadkison
Copy link
Contributor

jasonadkison commented Mar 9, 2018

You can set the default account directly on the client.
https://github.com/EthWorks/ethereum.rb/blob/master/lib/ethereum/client.rb#L14

You also need to set the key on the contract in order for it to be signed by your private key. See the section on signing transactions: https://github.com/EthWorks/ethereum.rb#signed-transactions

@ToJen
Copy link

ToJen commented Mar 27, 2018

@jasonadkison how did you achieve that?

@jasonadkison
Copy link
Contributor

@ToJen here's an example

key = Eth::Key.new(priv: YOUR_PRIVATE_KEY)
client = Ethereum::HttpClient.new(...)
client.default_account = key.address
contract = Ethereum::Contract.create(...)
contract.key = key

@kurotaky
Copy link
Collaborator

thanks for your report :)
If you still get the error, Can you show the behavior of the error in the following format?

### Steps to reproduce
<!-- Steps to reproduce the behavior -->

### Expected behavior
<!-- Tell us what should happen -->

### Actual behavior
<!-- Tell us what happens instead -->

### System configuration
**Ruby version**:
**Solc version**:
**Parity version**:
**OS**:

### Failure Logs
<!-- Please include any relevant log snippets or files here-->

@ghivert
Copy link
Author

ghivert commented Feb 22, 2020

I'm not using this package anymore. Should the issue be closed?

@kurotaky
Copy link
Collaborator

kurotaky commented Feb 22, 2020

@ghivert
All right. I'm going to close this issue 👍

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

No branches or pull requests

4 participants