@highkey-dev/sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.7-beta • Public • Published

SDK

Highkey is a frictionless way to onboard users into Web3—no seed phrases and no browser extensions! With the Highkey SDK, your users will be equipped with a decentralized, MPC-based, cross-chain wallet with just the touch of a finger, which they can use across all of Web3.

Currently supports the following chain types

  • EVM

NOTE Currently the SDK is in beta, do not use for sensitive data / assets. NOTE Backwards compatibility will not be guaranteed until after beta releases.

Quick Start

Registration session

const registrar = await WalletRegistrar.fromOptions(options)// create a wallet creation session for signing up users
if (!await registrar.startRegisterSession()) {
    throw new Error("failed to start session")
}// add callback
registrar.registerSession.onDeviceAdded = (guid: string, deviceName: string, credential: any) => {
    // use this device info to update your UI or state
    myState.devices.push({ guid, deviceName, credential })
}// add a credential for the current device to the session
await registrar.registerSession.addCurrentDevice()// closes the session and creates the wallet
const { wallet } = await registrar.registerSession.createWallet()

Get a Wallet

// get all wallets for an account
const wallets: Wallet[] = await resolveWalletsForAccount("<acct-name>")// find a wallet with a particular eth address
const wallet = wallets.find((w) => w.getAddress() === "0xsomething")

Authenticate a Wallet

// Create a login session
if (!await wallet.startLoginSession()) {
    throw new Error("failed to start session")
}

// Add callback for when signatures are added
wallet.loginSession.onSignatureAdded = (deviceId: string, signature: any) => {
    // use this info to update your UI or state
    myState.signatures.push({ deviceId, signature })
}

wallet.loginSession.onSignaturesReady = (signatures: DeviceSignature[]) => {
    // use this to know when the wallet is ready to sign
    const signedTxn = await wallet.signTransaction({ /* any txn */ })
    const result = await wallet.sendTransaction(signedTxn)
}

// create a signature for the credential stored on the host device
await wallet.loginSession.addCurrentDevice()

Sign and send transactions

const signedTxn = await wallet.signTransaction({ /* any txn */ })
const result = await wallet.sendTransaction(signedTxn)

Readme

Keywords

none

Package Sidebar

Install

npm i @highkey-dev/sdk

Weekly Downloads

0

Version

0.0.7-beta

License

none

Unpacked Size

12.3 MB

Total Files

95

Last publish

Collaborators

  • shadowysupercoder
  • brayden.cloud
  • josh-long145