Embed & Integrate

The Silk SDK is designed for ease of use by both seasoned Web3 devs and those new to self-custody wallets and cryptography.

1. Install

npm i @silk-wallet/silk-wallet-sdk

2. Use

Just getting started with Web3 development? You can easily embed Silk to your site following standard practices that minimizes bugs or performance issues. Silk exposes an EIP-1193-compliant interface, so you can use it just as you would use MetaMask, one of the most common Web3 wallet services. The only difference is that Silk must be initialized.

The following code initializes Silk, presents the login modal to the user, and gets the user's wallet addresses.

import { initSilk } from "@silk-wallet/silk-wallet-sdk"

// Initialize Silk
const silk = initSilk()

// Open the Silk login modal. silk.login() will throw if the user does not log in
try {
  await silk.login()
} catch (error) {
  console.error(error)
}

// Optional: Get the user's wallet addresses
const accounts = await silk.request({ method: 'eth_requestAccounts' })

If you want to customize this login flow with additional wallet options for web3-native users, you may choose to use the loginSelector method instead of the login method. This will let you set the options if a user chooses to sign in with a web3 wallet instead. See the Methods section for more details on how to do so.

Once users have logged in, you can use Silk as a Provider object with libraries such as viem, ethers, wagmi, or any other that supports EIP-1193 Providers. Simply pass the silkobject as the provider and you are good to go.

3. Examples

Silk + Next.js + Viem

Check out the repo for https://silk-template.vercel.app/

Questions or Trouble Integrating?

Reach out to us at silk@holonym.id or join our telegram group to ping the developer community with your question.

Last updated