npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@funkit/core

v2.2.4

Published

Funkit core SDK provides feature-rich and extensible smart wallets built on account abstraction

Downloads

2,024

Readme

backdrop

FunKit Core

FunKit empowers you to create feature-rich and extensible smart wallets built on account abstraction. Leveraging the FunKit, you can customize gas behavior, adopt multi-sig and common authentication method, monetize your application, execute any transactions from smart wallets, and much more.

This repo only covers FunKit Core SDK which does not provide any frontend specific optimizations. Check our Web SDK if you want to further simplify your application with our react hooks.

Table of Contents

  1. Installation
  2. Quick Start
  3. Testing
  4. More Resources

Installation

npm i @funkit/core --save
# or
yarn add @funkit/core

Quick Start

FunKit needs to be configured with an API key. Get a key by logging to our dashboard.

1. Import

Import all required classes.

import { FunWallet, configureEnvironment, Auth } from "@funkit/core"

2. Configure wallet environment

Set your environment variables describing how your smart wallets interact with blockchains. This can include chain, apiKey, and optional gasSponsor.

  1. chain - Each FunWallet exists on an EVM-compatible blockchain.
  2. apiKey - You can get an API key by logging to our dashboard.
  3. gasSponsor - All wallets have to pay gas to execute transactions on a blockchain. You can pre-fund the wallet with native tokens or you can have third parties to pay for gas by specifying a gasSponsor.
await configureEnvironment({
    chain: CHAIN_ID,
    apiKey: API_KEY,
    gasSponsor: {
        sponsorAddress: SPONSOR_ADDRESS
    }
})

3. Set up authentication

Next, you need a way to sign transactions. All authentication in FunKit is handled with the Auth object. You can use privateKey, viem client, web3 provider, ethers.js signer, rpcProvider or windowEth (MetaMask) to build the Auth. Check more examples about how to create auth with different inputs here

const auth = new Auth({ privateKey: PRIVATE_KEY })

4. Initialize the FunWallet

With the Auth instance that you just created, you can now initialize your FunWallet. Here are the FunWallet constructor parameters:

  1. users - This is a User[] that holds all users that can access your FunWallet. For simplicity, we’re only including 1 user here.
  2. uniqueId - This is a random seed that is generated from our Auth instance. The purpose of this seed is to generate the address of our FunWallet.
const wallet = new FunWallet({
    users: [{ userId: auth.getAddress() }],
    uniqueId: auth.getWalletUniqueId()
})

5. Initiate a Transfer

Now we have the wallet object, we will show how to transfer some basic ERC-20 tokens to other addresses. Note that the smart wallet will only be created on the blockchain after executeOperation is finished.

const transferOp = await wallet.transfer(auth, await auth.getUserId(), {
    to: RECIPIENT_ADDRESS,
    amount: AMOUNT,
    token: TOKEN_TO_SEND
})
const receipt = await funWallet.executeOperation(auth, transferOp)
console.log(receipt)

Testing

Testing on Goerli

You can test FunKit on Ethereum goerli testnet with the following configuration. We have a gas sponsor that will cover your gas cost for the first 200 operations so you don’t have to worry about pre-funding the wallet or setting up the gas sponsor to start.

await configureEnvironment({
    chain: "goerli",
    gasSponsor: {
        sponsorAddress: "0xCB5D0b4569A39C217c243a436AC3feEe5dFeb9Ad"
    },
    apiKey: API_KEY
})

More Resources

  • Documentation - Complete how-to guides and API reference docs.
  • Demo - Try FunKit Core in action.
  • Discord - Ask us a question, or just say hi!