Retrieve Ethereum Network and Account information on Mount and Display it in Svelte

Share this video with your friends

Send Tweet

Now the UI is capable to connect to the Ethereum network by using the wallet, but we need two more things to continue.

  1. Avoid re-connecting every time the browser is refreshed
  2. Get more information about the user and the network.

For the first, let's run a little function every time the component is mounted.

Then, let's read and display some more information:

  • The user balance
  • The network that the user is currently connected

Important

SvelteKit is still in beta. Expect bugs! Read more here, and track progress towards 1.0 here.

This lesson was recorded before the latest breaking changes, the content is still valid but it sometimes references a file that does not exists anymore.

Now: src/routes/index.svelte is called src/routes/+page.svelte

src/routes/__layout.svelte is called src/routes/+layout.svelte

Everything else is 100% valid. This particular content will be updated when Sveltekit reaches 1.0.0 stable.