Overview
svelte-web3 is a library that allows you to use the web3.js library as a collection of readable Svelte stores for Svelte or SvelteKit. If you prefer to use the ethers.js library to interact with EVM, you may be interested in the sister package svelte-ethers-store.
Features
- Readable Svelte stores: The library creates readable Svelte stores that are automatically updated when a new connection is established, or when the chain or selected account changes.
- Connection with browser provider: You can easily enable a connection with the current EIP-1193 provider injected in the browser window context by calling
setProvideron the library abstract helper with no argument. - Connection with non-injected providers: You can connect to non-injected EIP-1193 providers like web3-onboard, buidler.dev, ethers.js, eth-provider, WalletConnect, etc. by calling
setProvideron the library abstract helper with the JavaScript provider instance object of the library.
Installation
To install svelte-web3, follow these steps:
- Add the svelte-web3 package to your project.
- Add the web3.js library in the main HTML page (index.html in Svelte, src/template.html in Sapper, or src/app.html in SvelteKit).
Summary
svelte-web3 is a library that allows you to use the web3.js library as a collection of readable Svelte stores. It provides easy connection with both browser provider and non-injected EIP-1193 providers. With svelte-web3, you can effortlessly manage connections, accounts, and chain data in your Svelte or SvelteKit application.