Skip to content

Kredeum/wagmi-svelte5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

073df9e ยท Dec 29, 2024

History

14 Commits
Dec 28, 2024
Dec 24, 2024
Dec 27, 2024
Dec 28, 2024
Dec 26, 2024
Dec 12, 2024
Dec 27, 2024
Dec 25, 2024
Dec 28, 2024
Dec 29, 2024
Dec 26, 2024
Dec 25, 2024
Dec 29, 2024
Dec 27, 2024
Dec 27, 2024
Dec 25, 2024
Dec 26, 2024
Dec 26, 2024
Dec 25, 2024
Dec 28, 2024
Dec 27, 2024
Dec 27, 2024

Repository files navigation

@kredeum/wagmi-svelte5

A Svelte 5 Web3 library based on Wagmi, providing seamless integration of Web3 functionality into your Svelte applications.

โœจ Features

  • ๐Ÿ”Œ 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

๐Ÿ“ Repository Structure

This repository contains two main parts:

  • ๐Ÿ“ฆ The Svelte5 package code in src/lib/wagmi
  • ๐ŸŽฎ A SvelteKit demo app with usage examples in src/routes

๐Ÿ“ฆ Svelte5 Package

๐Ÿ’ป Installation

Add this package to your Svelte5 project:

npm install @kredeum/wagmi-svelte5
# or
pnpm install @kredeum/wagmi-svelte5
# or
yarn add @kredeum/wagmi-svelte5

๐Ÿš€ Quick Start

Simple Example

<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)}

Using this Counter class Helper

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");
  }
}

Same example without Helper

<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}

๐Ÿ“„ Smart Contract Source

// 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

๐ŸŽฎ SvelteKit Demo and Examples

The demo app in src/routes showcases various package features and usage patterns.

๐Ÿ› ๏ธ Requirements

Your local machine needs:

Optional but recommended:

โšก Quick Setup

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

๐Ÿค Contributing

We welcome contributions! Feel free to:

  • ๐Ÿ› Report issues
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ”ง Submit pull requests

๐Ÿ“„ License

MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

zapaz.eth zapaz@kredeum.com (http://labs.kredeum.com/)

About

Svelte5 Web3 library based on Wagmi

Resources

License

Stars

Watchers

Forks

Packages

No packages published