-
What we want to do
• Let the user sign in with their wallet.
• Get an “identity” we can use when we talk to any canister. -
Step-by-step code
TypeScript
Copy
// 1. Bring in the helpers
import { IcpWallet } from '@dfinity/oisy-wallet-signer/icp-wallet';
// 2. Connect the wallet once (e.g., in an async function)
const wallet = await IcpWallet.connect({
url: walletUrl.value, // “https://wallet.oisy.com” (or whatever you show the user)
onDisconnect: () => { // runs when user logs out of the wallet
console.log('Wallet was closed or logged out');
},
});
// 3. Grab an identity that can be used with ANY canister
const oisyIdentity = wallet.identity; // <-- this is the magic “oisy identity”
// 4. Use that identity when you create an actor
import { createActor } from 'declarations/my_canister'; // auto-generated or your own helper
const actor = createActor(canisterId, {
agentOptions: { identity: oisyIdentity }, // plug the wallet identity in here
});