Fuelet | Wallet on Fuel
  • Introduction
  • Intergration guide
    • Intro
    • Detecting wallet presence
    • Selecting Fuelet as a connector
    • Best practice
    • Audit and Security Assurance
  • Wallet API
    • Intro
    • Connecting
    • Getting current account
    • Getting current network
    • Signing messages
    • Sending transactions
    • Events
  • Resources
    • Media Kit
Powered by GitBook
On this page
  1. Wallet API

Signing messages

Last updated 1 year ago

You can request a user to sign a message with a private key of his connected account. This can be achieved in two ways.

You can call the signMessage on the fuel object providing the account address (in ) you want to sign message with, and the message itself:

const signature = await fuel.signMessage('fuel1j0nym7r7twmy8cs6gx2yhd042n38znkeghyjw3dtp0g6tkju34zq2fwltf', 'Message to sign');
console.log("Sign message response", signature);

Or you can get an instance of the wallet first and then call the signMessage method on it:

const wallet = await fuel.getWallet('fuel1j0nym7r7twmy8cs6gx2yhd042n38znkeghyjw3dtp0g6tkju34zq2fwltf');
const signature = await wallet.signMessage('Message to sign');
console.log("Sign message response", signature);

After calling any of the methods, the app will prompt the user to authorize the request. The following screen will appear:

Once the user approves the request, the promise is finalized with a string - the signature. If anything goes wrong, e.g. the user cancels the request, the method call will result in an exception.

Bech32 format