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

@kresuslabs/kconnect

v0.5.0

Published

Downloads

18

Readme

KresusConnect

Kresus connect SDK is built for Dapps to provide their users the ability to connect using Kresus Wallet and perform transactions. Kresus connect SDK also offers insta-wallet capability through which users can get a web3 wallet instantly.

1. Installing Kresus Connect

You can install Kresus Connect via yarn or NPM

Yarn Install

yarn add  @kresuslabs/kconnect

Npm Install

npm install @kresuslabs/kconnect

2. Obtain Project ID & Referral Id

Head over to WalletConnect Cloud to sign in or sign up. Create (or use an existing) project and copy its associated Project ID. We will need this in a later step.

Please email us at [email protected] with the projectId and other details to setup the referral id.

3. Setting up Kresus Connect SDK

This page describes how to set up the Kresus Connect SDK prerequisites

In order to develop properly with the kresus connect SDK you need the following A functional node project set up for local development Web3.js and @kresuslabs/kconnect installed using npm install web3 or similar A valid WalletConnect Project Id Initializing In your App.tsx file, add the following code to initialize Kresus Connect SDK and a Web3 object:

const projectId = '89b2f****************7f4cf'

const kconnect = await Kconnect.init({
  projectId: projectId,
  refid: referralId,
  metadata: {
    name: 'OpenSea',
    description: 'World’s largest NFT Marketplace',
    url: 'https://opensea.io/',
    icons: ['https://opensea.io/static/images/logos/opensea-logo.svg']
  }
})

4. Connect to wallet

In your App.tsx file, add the following code to display a QR code to users.

const session = await kconnect.connect({
    // Provide the namespaces and chains (e.g. `eip155` for EVM-based chains) we want to use in this session.
    requiredNamespaces: {
      eip155: {
        methods: [
          'eth_sendTransaction',
          'eth_signTransaction',
          'eth_sign',
          'personal_sign',
          'eth_signTypedData'
        ],
        chains: ['eip155:1'],
        events: ['chainChanged', 'accountsChanged']
      }
    }
  })

When the connect wallet button is pressed, kconnect.connect should be called, which initiates kresus Modal to take over and displays a QR code.

When the QR is successfully scanned by Kresus SuperApp Mobile app, a valid session would be established which can be checked using session.acknowledged

5. Displaying Wallet Address

const walletAddress = session.namespaces.eip155.accounts[0];

7. Switching between Chains

For switching networks, while establishing connection, all the supported chains should be added as optionalNamespaces

const chain = "eip155:179"
const methods = [
          'eth_sendTransaction',
          'eth_signTransaction',
          'eth_sign',
          'personal_sign',
          'eth_signTypedData'
        ]
const response = kconnect.switchNetwork(chain,methods)

8. Create Message Sign Request

 const handleSignMessage =  async () => {

const msg = "0x7468697320697320612074657374206d65737361676520746f206265207369676e6564"

const address = "0x1d85568eEAbad713fBB5293B45ea066e552A90De"

const param = [     ,
     msg,
     address
   ]


const result = await kconnect.request({
 topic: session.topic,
 chainId: 'eip155:1',
 request: {
   method: "personal_sign",
   params: param ,
   });   
} 

await handleSignMessage()

This will send the message to sign to the Kresus SuperApp

9. Create Tx Request

 const handleSendTransaction =  async () => {
   const tx = {
     from: walletAddress,
     to: "0xBDE1EAE59cE082505bB73fedBa56252b1b9C60Ce",
     data: "0x",
     gasPrice: "0x8BB2C97000",
     gasLimit: "0x5208",
     value: "0x0111",
   };

   const result = await kconnect.request({
     topic: session.topic,
     chainId: "eip155:1",
     request: {
       method: "eth_sendTransaction",
       params: [tx],
     },
   })
   console.log(result);
 }

await handleSendTransaction();

This example will create sample transaction and send to Kresus SuperApp to sign.