A Svelte 5 Web3 library based on Wagmi, providing seamless integration of Web3 functionality into your Svelte applications.
- ๐ Built for Svelte 5 with full TypeScript support
- ๐ Web3 Integration using Wagmi core functionality
- ๐ Secure Wallet Connection Management
- โ๏ธ Multi-chain Support with Auto-detection
- ๐ฃ Reactive Web3 Hooks for Real-time Updates
- ๐ Auto-refresh on Network Changes
- ๐ฆ Simple and Intuitive API
- ๐ ๏ธ Type-safe Contract Interactions
This repository contains two main parts:
- ๐ฆ The Svelte5 package code in
src/lib/wagmi
- ๐ฎ A SvelteKit demo app with usage examples in
src/routes
Add this package to your Svelte5 project:
npm install @kredeum/wagmi-svelte5
# or
pnpm install @kredeum/wagmi-svelte5
# or
yarn add @kredeum/wagmi-svelte5
<script lang="ts">
import { newWagmi } from "@kredeum/wagmi-svelte5";
import { Counter } from "$lib/examples/Counter.svelte";
newWagmi();
const counter = new Counter();
</script>
{counter.number}ยฒ = {counter.square(counter.number)}
import { SmartContract } from "$lib/wagmi";
export class Counter extends SmartContract {
get number() {
return this.call("number") as bigint;
}
square(num: number | bigint) {
return this.call("square", [num]) as bigint;
}
constructor() {
super("Counter");
}
}
<script lang="ts">
import { newWagmi, SmartContract } from "@kredeum/wagmi-svelte5";
newWagmi();
const contract = new SmartContract("Counter");
const num = $derived(contract.call("number"));
const square = $derived(contract.call("square", [num]));
</script>
{num}ยฒ = {square}
// Counter.sol
contract Counter is ICounter {
uint256 public number;
function square(uint256 num) public pure override(ICounter) returns (uint256) {
return num ** 2;
}
...
}
Full Counter.sol code deployed on Base Sepolia testnet can be Viewed here: ๐ on BaseScan
The demo app in src/routes
showcases various package features and usage patterns.
Your local machine needs:
Optional but recommended:
- ๐ Turborepo 1.8+
Get started with the examples:
# Clone the repository
git clone https://github.com/kredeum/wagmi-svelte5.git
cd wagmi-svelte5
# Install dependencies
pnpm install
# Run the demo app
turbo start
# or without Turborepo
pnpx turbo start
๐ Your browser will open to http://localhost:5173 showing the Tests
page
We welcome contributions! Feel free to:
- ๐ Report issues
- ๐ก Suggest features
- ๐ง Submit pull requests
MIT License - see the LICENSE file for details.
zapaz.eth zapaz@kredeum.com (http://labs.kredeum.com/)