Methods
Human Wallet implements the EIP-1193 request
method, which covers most common use cases. For additional features, it implements additional methods below:
// --- Methods exported from "@silk-wallet/silk-wallet-sdk" ---
/**
* Initialize Human Wallet SDK
*/
initSilk(options?: InitSilkOptions): SilkProvider
// --- Methods on SilkProvider ---
interface SilkProvider {
/**
* Open the Human Wallet login modal.
* Returns the login type: 'human', 'injected', 'walletconnect', or null if the user cancels.
*/
login(injectedProvider?: EthereumProvider): Promise<'human' | 'injected' | 'walletconnect' | null>
/**
* Get the current login method without triggering a connection.
* Returns the active login method or null if not connected.
*/
getLoginMethod(): 'human' | 'injected' | 'walletconnect' | null
/**
* EIP-1193 compliant request method with auto-connect functionality.
*/
request(args: { method: string, params?: unknown[] | object }): Promise<unknown>
/**
* Log out the user (Human Wallet and WalletConnect only).
*/
logout(): Promise<void>
/**
* Request the user's email address (Human Wallet only).
*/
requestEmail(): Promise<string>
/**
* Prompt the user to mint a Zeronym SBT (Human Wallet only).
*/
requestSBT(type: 'kyc' | 'phone'): Promise<string | null>
}
Method Details​
initSilk
​
Initializes the Human Wallet SDK and sets up window.silk
. Must be called before using any other methods.
import { initSilk } from "@silk-wallet/silk-wallet-sdk";
const options = {
config: {
allowedSocials: [
"google",
"twitter",
"discord",
"coinbase",
"linkedin",
"apple",
],
authenticationMethods: ["email", "phone", "social", "wallet"],
styles: { darkMode: true },
},
useStaging: true,
walletConnectProjectId: "<PROJECT_ID>", // Required if 'wallet' in authenticationMethods
referralCode: "your-referral-code", // Optional
};
initSilk(options);
login
​
Opens the Human Wallet login modal and returns the wallet type the user chose.
- Returns:
'human' | 'injected' | 'walletconnect' | null
- Parameters:
injectedProvider
(optional): Custom provider to use for injected wallet option
const loginType = await window.silk.login();
switch (loginType) {
case "human":
console.log("User chose Human Wallet");
break;
case "injected":
console.log("User chose injected wallet (e.g., MetaMask)");
break;
case "walletconnect":
console.log("User chose WalletConnect");
break;
case null:
console.log("User cancelled login");
break;
}

getLoginMethod
​
Returns the current login method without showing any UI. Useful for checking connection state and determining logout behavior.
- Returns:
'human' | 'injected' | 'walletconnect' | null
- Validates: Automatically checks if the connection is still valid and cleans up invalid states
const loginMethod = window.silk.getLoginMethod();
// Use for conditional UI
if (loginMethod === "human") {
// Show Human Wallet specific features
document.getElementById("email-button").style.display = "block";
} else if (loginMethod === "injected") {
// Hide logout button (can't logout programmatically)
document.getElementById("logout-button").style.display = "none";
} else if (loginMethod === "walletconnect") {
// Show standard wallet UI
} else {
// User not connected
document.getElementById("connect-button").style.display = "block";
}
request
​
EIP-1193 compliant request method with built-in auto-connect functionality.
- Auto-Connect: When calling
eth_requestAccounts
, automatically attempts to reconnect using the user's previous login method - Fallback: If auto-connect fails, falls through to normal Human Wallet flow
// This will auto-connect if user was previously logged in
const accounts = await window.silk.request({
method: "eth_requestAccounts",
});
// Standard EIP-1193 methods work as expected
const balance = await window.silk.request({
method: "eth_getBalance",
params: [accounts[0], "latest"],
});
const txHash = await window.silk.request({
method: "eth_sendTransaction",
params: [
{
from: accounts[0],
to: "0x...",
value: "0x123",
},
],
});
logout
​
Logs out the user and clears stored session data. Behavior depends on the login method:
- Human Wallet / WalletConnect: Full logout with session cleanup
- Injected Wallets: Clears app-level session but cannot disconnect the wallet itself
await window.silk.logout();
console.log(window.silk.getLoginMethod()); // Returns null
requestEmail
​
Requests the user's verified email address (Human Wallet only).
try {
const email = await window.silk.requestEmail();
console.log("User email:", email);
} catch (error) {
console.log("User declined to share email");
}

requestSBT
​
Prompts the user to mint a Zeronym Soulbound Token (Human Wallet only).
- Parameters:
'kyc'
or'phone'
- Returns: User's address if successful, null if already minted
- Throws: Error if user exits before completion
try {
const address = await window.silk.requestSBT("phone");
if (address) {
console.log("SBT minted for address:", address);
} else {
console.log("User already has this SBT");
}
} catch (error) {
console.log("User cancelled SBT minting");
}
Auto-Connect Functionality​
Human Wallet automatically attempts to reconnect users when they refresh the page or return to your application.
How It Works​
- Login Choice Remembered: When users log in via
login()
, their wallet choice is stored - Seamless Reconnection: Calling
eth_requestAccounts
automatically attempts to reconnect using their previous method - Graceful Fallback: If reconnection fails (e.g., wallet extension disabled), it falls back to normal Human Wallet flow
Implementation Patterns​
Auto-Connect:
// Simple approach - just call eth_requestAccounts
try {
const accounts = await window.silk.request({ method: "eth_requestAccounts" });
console.log("Connected:", accounts[0]);
} catch (error) {
console.log("Connection failed, show login button");
}
Logout and Session Management​
Simple Logout (Human Wallet Only)​
await window.silk.logout();
Smart Logout (With External Wallets)​
When external wallets are enabled, use getLoginMethod()
to handle different logout flows:
async function smartLogout() {
const loginMethod = window.silk.getLoginMethod();
switch (loginMethod) {
case "human":
case "walletconnect":
// Can logout programmatically
await window.silk.logout();
console.log("Logged out successfully");
break;
case "injected":
// Cannot logout programmatically
showDisconnectInstructions();
// Still call logout to clear app session
await window.silk.logout();
break;
case null:
console.log("User not connected");
break;
}
}
function showDisconnectInstructions() {
alert(
"To disconnect, open your wallet extension (e.g., MetaMask), " +
'go to "Connected Sites", and remove this site. ' +
"You can still connect with Human Wallet or WalletConnect " +
"without disconnecting your injected wallet."
);
}
Logout State Management​
// Complete logout with UI updates
async function logout() {
const loginMethod = window.silk.getLoginMethod();
// Clear UI state
setConnectedAccount(null);
setLoginMethod(null);
// Handle wallet-specific logout
if (loginMethod === "injected") {
showManualDisconnectMessage();
}
// Always call logout to clear session
await window.silk.logout();
// Verify logout was successful
console.log("Login method after logout:", window.silk.getLoginMethod()); // null
}
Event Listeners​
Human Wallet implements standard EIP-1193 event listeners:
// Connection status changes
window.silk.on("connect", () => {
console.log("Connected to Human Wallet");
});
// Account changes
window.silk.on("accountsChanged", (accounts) => {
if (accounts.length === 0) {
console.log("Wallet disconnected");
setConnectedAccount(null);
} else {
console.log("Account changed to:", accounts[0]);
setConnectedAccount(accounts[0]);
}
});
// Chain changes
window.silk.on("chainChanged", (chainId) => {
console.log("Chain changed to:", chainId);
setCurrentChain(chainId);
});
// Disconnect events
window.silk.on("disconnect", (error) => {
console.log("Wallet disconnected:", error);
setConnectedAccount(null);
});
Event Cleanup​
useEffect(() => {
const handleAccountsChanged = (accounts) => {
setConnectedAccount(accounts[0] || null);
};
const handleChainChanged = (chainId) => {
setCurrentChain(chainId);
};
// Add listeners
window.silk.on("accountsChanged", handleAccountsChanged);
window.silk.on("chainChanged", handleChainChanged);
// Cleanup on unmount
return () => {
window.silk.removeListener("accountsChanged", handleAccountsChanged);
window.silk.removeListener("chainChanged", handleChainChanged);
};
}, []);
Questions or Trouble Integrating?​
Please join our Developer Discord to get in touch with a support representative.