Martian Wallet Dev Docs
HomeChrome web store
  • Introduction
  • 🏗️Integration
    • Detecting the Provider
    • Establishing a Connection
    • Displaying Your App
  • ⚙️methods
    • Aptos
      • Generate Transaction
      • Sign Transaction
      • Submit Transaction
      • Sign and Submit Transaction
      • Sign Generic Transaction
      • Generate Sign and Submit Transaction
      • Create Collection
      • Create Token
      • Add Network
      • Change Network
      • Get Networks
      • Get Transaction
      • Get Transactions
      • Get Account Transactions
      • Get Account Resources
      • Get Account
      • Get Chain Id
      • Get Ledger Info
    • Sui
      • Sign Transaction Block
      • Sign and Execute Transaction
      • Get Public Key
      • Get Old Address
      • Get Accounts
    • Sign Message
    • Get Network
    • Get Current Blockchain
    • Cancel Submitted Transactions
    • Network Change Event
    • Account Change Event
Powered by GitBook
On this page
  1. methods

Sign Message

PreviousGet AccountsNextGet Network

Last updated 2 years ago

Once an application is connected to Martian wallet via method, it can also request that the user signs a given message using given api. Applications are free to write their own messages which will be displayed to users from within Martian's signature prompt. Message signatures do not involve network fees and are a convenient way for apps to verify ownership of an address. It takes one parameter listed below:

{
   address?: boolean; // Should we include the address of the account in the message
   application?: boolean; // Should we include the domain of the dapp
   chainId?: boolean; // Should we include the current chain id the wallet is connected to
   message: string; // The message to be signed and displayed to the user
   nonce: string; // A nonce the dapp should generate,
}
{
   message: string || Uint8Array; // The message to be signed and displayed to the user
}

For more information on how to verify the signature of a message, please refer to .

Below is an example code describing the way to sign a message.

const metadata = {
  address: true,
  application: true,
  chainId: true,
  message: "This is a sample message",
  nonce: 12345,
};
const signature = await window.martian.signMessage(metadata);
console.log(signature)
// {
//     "address": "0x34c1e7efa0808b7b0113d71b722f483585e4c4b47ba2b0e703b090937f0c63a1",
//     "application": "main.d3c4qcdwu8dzdc.amplifyapp.com",
//     "chainId": 25,
//     "message": "This is a sample message",
//     "nonce": 12345,
//     "fullMessage": "APTOS\naddress: 0x34c1e7efa0808b7b0113d71b722f483585e4c4b47ba2b0e703b090937f0c63a1\napplication: main.d3c4qcdwu8dzdc.amplifyapp.com\nchainId: 25\nmessage: This is a sample message\nnonce: 12345",
//     "prefix": "APTOS",
//     "signature": "0x6f9ee0929285b83d385b93ac615784964269e64d756c9538d5fd8c999d9c5b4d3085c363cd034ecd537ea9e522ea0a2a8c7ab898b79b0eb4d7b3cb853291f801"
// }
const metadata = {
  message: "<Uint8Array>",
};
const signature = await window.martian.sui.signMessage(metadata);
console.log(signature)
// {
//     "messageBytes": string
//     "signature": string
// }
⚙️
tweetnacl-js
connect