Signing
Sign data on Cardano using OneKey
Learn how to sign data for authentication on Cardano.
Sign Data (CIP-8)
Sign arbitrary data for authentication:
const api = await window.cardano.onekey.enable()
const addresses = await api.getUsedAddresses()
const address = addresses[0]
// Message to sign
const payload = Buffer.from('Hello Cardano!').toString('hex')
const signature = await api.signData(address, payload)
console.log({
signature: signature.signature, // COSE_Sign1 signature
key: signature.key, // COSE_Key public key
})Verify Signature
Error Handling
Common Errors
Code
Description
-1
User rejected
-2
Account not found
-3
Invalid network
Last updated
Was this helpful?