Skip to Content
Connect to Software

signMessage

Wallet & Address Type Support Matrix

Signing MethodWallet TypeSupported Address Types
ECDSASoftware & HardwareP2PKH, P2SH, P2WPKH, P2TR
BIP322-SimpleSoftwareP2WPKH, P2TR
BIP322-SimpleHardware (Pro, Classic1S)P2TR

Sign a message using either ECDSA or BIP322-Simple signing method.

Method

async function signMessage( message: string, type?: "ecdsa" | "bip322-simple" ): Promise<string>

Params

  • messagerequired string A string to sign
  • typeoptional string Signing method type, either “ecdsa” or “bip322-simple”. Default is “ecdsa”

Returns

signaturestring The signed message signature

Examples

const provider = (window.$onekey && window.$onekey.btc) || window.unisat; // Sign with ECDSA (default) try { const message = "Hello OneKey"; const signature = await provider.signMessage(message); console.log("ECDSA signature:", signature); } catch (e) { console.error("Error signing with ECDSA:", e); } // Sign with BIP322-Simple try { const message = "Hello OneKey"; const signature = await provider.signMessage(message, "bip322-simple"); console.log("BIP322-Simple signature:", signature); } catch (e) { console.error("Error signing with BIP322-Simple:", e); }

Demo

Last updated on