Function Signature
function linkWallet(
options: Options
): Promise<Response>;
options
[Options](/sdk-reference/types#linkwallet-options)
The options for linking a wallet to a user ID.
Promise
Promise<[Response](/sdk-reference/types#linkwallet-response)>
A promise that resolves with the response from linking a wallet.
Type Definitions: For detailed type information including all properties and their descriptions, visit the Types page.
Usage
import { TrustEngineSDK } from '@trust-engine/sdk';
import { useState } from 'react';
const sdk = new TrustEngineSDK();
export default function UserKeyLinker() {
const [userID, setUserID] = useState('');
const [walletAddress, setWalletAddress] = useState('');
const [isLinking, setIsLinking] = useState(false);
const [result, setResult] = useState<any | null>(null);
const handleLink = async () => {
if (!userID || !walletAddress) return;
setIsLinking(true);
try {
const linkResult = await sdk.linkWallet({ userID, walletAddress });
setResult(linkResult);
} catch (error) {
console.error('❌ Failed to store relation:', error.message);
setResult({ error: error.message });
} finally {
setIsLinking(false);
}
};
return (
<div>
<input
type="text"
value={userID}
onChange={(e) => setUserID(e.target.value)}
placeholder="Enter User ID"
/>
<input
type="text"
value={walletAddress}
onChange={(e) => setWalletAddress(e.target.value)}
placeholder="Enter Wallet Address"
/>
<button onClick={handleLink} disabled={isLinking}>
{isLinking ? 'Linking...' : 'Link User and Wallet'}
</button>
{result && <pre>{JSON.stringify(result, null, 2)}</pre>}
</div>
);
}