Signing

Sign messages on Algorand using OneKey

Learn how to sign messages for authentication on Algorand.


Sign Arbitrary Message

const message = new TextEncoder().encode('Hello Algorand!')

const { signature, address } = await provider.signMessage(
  message,
  'utf8' // or 'base64'
)

console.log('Signature:', signature)
console.log('Signer:', address)

Verify Signature


const message = new TextEncoder().encode('Hello Algorand!')
const { signature } = await provider.signMessage(message)

// Get public key from address
const publicKey = algosdk.decodeAddress(provider.address).publicKey

const isValid = nacl.sign.detached.verify(message, signature, publicKey)
console.log('Valid:', isValid)

Error Handling


Common Error Codes

Code
Description

4001

User rejected request

4100

Unauthorized

4200

Unsupported method

4300

Invalid input

Last updated

Was this helpful?