Methods

For developers, the SilkEthereumProviderInterface provides the top-level functional description.

In addition to the EIP-1193 request and other methods, it defines the following SilkProvider methods:

// --- Methods exported from "@silk-wallet/silk-wallet-sdk" ---
/**
 * @param [referralCode] - Silk points referral code
 */
initSilk(referralCode?: string): SilkProvider

// --- Methods on SilkProvider ---
interface SilkProvider {
 /**
  * Open the Silk login modal (without other wallet options). 
  * Returns null if the user logs in. 
  * Throws an error if the user exits without logging in.
  */
 login(): Promise<null>
 /**
  * Open the Silk login modal (with other wallet options). 
  * Returns a string denoting the wallet selected by the user. 
  * Throws an error if the user exits without logging in.
  * @param [injectedProvider] - window.ethereum. The text for the button for the 
  * injected wallet in the login modal changes based on which wallet this is.
  */
 loginSelector(injectedProvider?: EthereumProvider): Promise<'silk' | 'injected' | 'walletconnect'>
 /**
  * Request the user's email address.
  */
 requestEmail(): Promise<string>
 /**
  * Prompt the user to mint a Zeronym SBT.
  * Returns the user's address if they successfully mint the SBT, null if
  * they have already minted before.
  * Throws an error if the user exits before minting.
  */
 requestSBT(type: 'kyc' | 'phone'): Promise<string | null>
 /**
  * This function is implemented as described in EIP-1193 
  * (https://eips.ethereum.org/EIPS/eip-1193#request).
  */
 request(args: { method: string, params?: unknown[] | object }): Promise<unknown>
}

Method Details

login

This method triggers the Login / Signup user flows in the Silk modal

loginSelector

The loginSelector method opens the Silk modal to display wallet options with which to sign transactions as alternatives to Silk. This provides more flexibility for application developers with audiences who might already be familiar with web3 infrastructure and have existing wallets.

requestEmail

By calling the requestEmail function, the Silk modal asks users to consent to sharing their verified email address with the application. By relying on the same email that Silk users verify on every Silk login, applications can opt to skip their own implementation of user email verification.

requestSBT

Calling requestSBT opens the user flow for a specific Proof of Identity to be completed and mint a soul-bound token. The method returns with the user's address if successfully completed. Currently supported parameters to pass to this function are "phone" and "kyc".

request

The request function is a direct implementation of the EIP-1193 Ethereum Provider JavaScript API. This allows developers and 3rd-party tools to treat Silk as a 1193-compliant EVM wallet, e.g. to list it alongside other wallets.

Last updated