0.0.7-beta • Published 11 months ago

@highkey-dev/sdk v0.0.7-beta

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

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)
0.0.7-beta

11 months ago

0.0.6-beta

11 months ago

0.0.5-beta

1 year ago

0.0.4-beta

1 year ago

0.0.3-beta

1 year ago

0.0.2-beta

1 year ago

0.0.1-beta

1 year ago