Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chiuzon/svelteweb3

A simple, dependency minimized package for building modern dApps with Svelte
https://github.com/chiuzon/svelteweb3

dapps ethereum react svelte sveltejs web3

Last synced: 18 days ago
JSON representation

A simple, dependency minimized package for building modern dApps with Svelte

Awesome Lists containing this project

README

        

# `svelteWeb3`

A simple, dependency minimized package for building modern dApps with Svelte

## ⚠️ Warning 0.3.0
After 0.3.0 version we don't do any polyfills for the `web3-react` connectors, the `injected-connector` works without any polyfills but packages like `walletconnect-connector` might require `buffer` polyfill.\

For some connectors you might be required to disable `ssr`

## Projects using `svelteWeb3`

`Open a PR to add your project to the list!`

## Installation

`pnpm install @chiuzon/svelteweb3`

## Usage

```js
//store.js
import { createWeb3Store } from '@chiuzon/svelteweb3'

//You can have any number of Web3Store
export const web3Store = createWeb3Store((provider) => {
return new ethers.providers.Web3Provider(provider)
})
```

```svelte
//index.svelte

import { web3Store } from './store.js'
import { InjectedConnector } from '@web3-react/injected-connector'

const injectedConnector = new InjectedConnector({supportedChainIds: [1]})

const {account, activate} = web3Store

async function onConnectHandle() {
await activate(injectedConnector, (error) => {
console.error(error)
})
}

Account Address: {$account}

{
onConnectHandle()
}}>Connect
```

## Local Development

- Clone repo\
`https://github.com/chiuzon/svelteWeb3`

- Install dependencies\
`pnpm install`

- Build and watch for changes\
`pnpm dev`