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

Accounts.push() error, When I not use #[tokio::main] and async? #645

Open
peter-jim opened this issue Jun 3, 2022 · 1 comment
Open

Comments

@peter-jim
Copy link

I want to try not use #[tokio::main] in my project . it show error follow this.

{unknown}
no method named push found for struct CallFuture in the current scope
method not found in CallFuture<Vec<H160>, Pin<Box<dyn std::future::Future<Output = Result<serde_json::value::Value, web3::Error>> + std::marker::Send>>>rustcE0599


my code is

let mut accounts = web3.eth().accounts();
accounts.push(hex!("0x5940C8F24c1c6ee04e0F7E1f44546d71859Cc3b7").into());

Is there a way I can run successfully without # [tokio::main] and async?

@elpiel
Copy link
Contributor

elpiel commented Jul 11, 2022

I believe that the current implementation runs only in async.
One way you could run it in blocking code is e.g. using the futures crate: https://docs.rs/futures/latest/futures/executor/fn.block_on.html
or even better, with the exactly the same function exported by web3:
https://docs.rs/web3/latest/web3/fn.block_on.html

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

2 participants