Connect
Cometh ConnectCometh MarketplaceCometh Checkout
  • Demo
  • 🚀QUICKSTART
    • What is Connect
    • Getting started
    • Supported Networks
    • Connect 4337
  • ⚒️FEATURES
    • Create a wallet
    • Send transactions
    • Sign/Verify a message
    • Retrieve a wallet Address
    • Import a Safe wallet
    • Handle wallet owners
  • 🔌Integrations
    • Ethers
    • Wagmi - Viem
      • Viem
      • Wagmi
      • Wagmi + Rainbowkit
      • Wagmi + Web3modal
    • Unity
    • React issues
      • Vite
      • Create React App
  • 📖RESOURCES
    • FAQ
    • Advanced features
      • Add a new device
      • Recover users wallets
    • General concepts
      • Biometric signers
      • Multiple devices
      • Account Recovery
      • Gasless transaction
Powered by GitBook
On this page
  1. FEATURES

Sign/Verify a message

You can sign and verify messages in just 1 line of code.

Last updated 1 year ago

With Cometh Connect, we deploy a smart account for our users.

When you use a smart account, you need to follow the for signature verification. You have to call the isValidSignature function available on the smart contract (here is a more ). We created that facilitates smart account signature verification using viem.

With Connect, we deploy the smart account at the first transaction of the user, allowing to reduce gas cost for our clients (it's a feature called lazy deployment). You might want to verify the signature of a wallet that is not yet deployed.

To facilitate that, we created an endpoint that allows you to verify an account signature, whether the account is deployed or not:

In practice, this is what it looks like:

import {
  ComethWallet,
  ConnectAdaptor,
  ComethProvider,
  SupportedNetworks
} from '@cometh/connect-sdk'

const api = axios.create({ baseURL: "https://api.connect.cometh.io"});
api.defaults.headers.common["apikey"] = API_KEY;

const walletAdaptor = new ConnectAdaptor({
  chainId: YOUR_CHAIN_ID,
  apiKey: API_KEY
})

const wallet = new ComethWallet({
  authAdapter: walletAdaptor,
  apiKey: API_KEY,
  rpcUrl: RPC_URL
})

await wallet.connect(OPTIONAL_WALLET_ADDRESS)

const message = "hello world";
const signature = await wallet.signMessage(message);

const body = { message, signature };
const response = await api.post(`/wallets/${walletAddress}/is-valid-signature`, body);

const verificationResult = response.data.result
⚒️
EIP1271 standard
detailed explanation
a library

Verify signature

post

Verify the signature for a given message following EIP1271. This will work even if the safe wallet is not deployed yet as it will use the predicted wallet address for the EOA that signed the message.

Path parameters
walletAddressstringRequired

A wallet address

Example: 0x7Fc751C1725F3B955Aa8781640E1BAf5B75684c2Pattern: ^0x[a-fA-F0-9]{40}$
Header parameters
apikeystringRequired

A string representation of a customer ApiKey.

Example: 4fd84958-1bab-4e1c-9778-46d2639d3196
Body
signaturestringRequired

The signature associated to the message.

Example: 0x4D33B9C8A02EC9a892C98aA9561A3e743dF1FEA3Pattern: ^0x[a-fA-F0-9]{40}$
messagestringRequired

Message signed by the user.

Example: hello world
Responses
200
Successfull operation and verification result
application/json
500
Internal server error
application/json
post
POST /wallets/:walletAddress/is-valid-signature HTTP/1.1
Host: api.connect.cometh.io
apikey: 4fd84958-1bab-4e1c-9778-46d2639d3196
Content-Type: application/json
Accept: */*
Content-Length: 82

{
  "signature": "0x4D33B9C8A02EC9a892C98aA9561A3e743dF1FEA3",
  "message": "hello world"
}
{
  "success": true,
  "result": true
}