I am a beginner trying to access the ethereum global object from window in web-sys. This is what I've tried so far. How can I get the ethereum object?

let window: Window = window().unwrap();
let ethereum = window.open("ethereum").unwrap()
.dyn_into::<web_sys::Object>().unwrap("Cannot find ethereum object");

Using js-sys allows you to get the ethereum value from window as seen below

use js_sys;

...
let window: Window = window().unwrap();
let ethereum = js_sys::Reflect::get(&window, &"ethereum".into());
...

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.