Authentication
Use Sui WalletCopied!
You can connect to Tusky with a Sui wallet of your choice.
browser
import { Tusky } from "@tusky-io/ts-sdk/web";
import { useCurrentAccount, useSignPersonalMessage } from "@mysten/dapp-kit";
// Sui wallet extension
const account = useCurrentAccount();
const { mutate: signPersonalMessage } = useSignPersonalMessage();
const tusky = new Tusky({ wallet: { signPersonalMessage, account } });
// sign-in to Tusky (this will prompt the wallet & ask for user signature)
await tusky.auth.signIn();
server
import { Tusky } from "@tusky-io/ts-sdk";
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
// generate new Sui Key Pair or import an existing one
const keypair = new Ed25519Keypair();
const tusky = new Tusky({ wallet: { keypair } });
await tusky.auth.signIn();
Use Api KeyCopied!
If you are integrating our SDK for Node.js scripts or server-side setup, you can authenticate by using your API key.
You can generate fresh API key here: https://app.tusky.io/account/api-keys
import { Tusky } from "@tusky-io/ts-sdk";
const tusky = new Tusky({ apiKey: "your-api-key" });