Skip to content

Frog.signature

Import

import { Frog } from 'frog'

Usage

import { Button, Frog, parseEther } from 'frog'
 
const app = new Frog({ title: 'Frog Frame' })
 
app.signature('/sign', (c) => {
  // Sign Typed Data.
  return c.signTypedData({
    chainId: 'eip155:84532',
    domain: {
      name: 'Ether Mail',
      version: '1',
      chainId: 1,
      verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
    },
    types: {
      Person: [
        { name: 'name', type: 'string' },
        { name: 'wallet', type: 'address' },
        { name: 'balance', type: 'uint256' },
      ],
      Mail: [
        { name: 'from', type: 'Person' },
        { name: 'to', type: 'Person' },
        { name: 'contents', type: 'string' },
      ],
    },
    primaryType: 'Mail',
    message: {
      from: {
        name: 'Cow',
        wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
        balance: 0n,
      },
      to: {
        name: 'Bob',
        wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
        balance: 1n,
      },
      contents: 'Hello, Bob!',
    },
  })
})

Parameters

path

  • Type: string

Path of the route.

Read more.

import { Button, Frog, parseEther } from 'frog'
 
const app = new Frog({ title: 'Frog Frame' })
 
app.signature(
  '/sign',
  (c) => { 
    // Send signature response. 
    return c.signTypedData({
      chainId: 'eip155:84532',
      types: {
        Swamp: [{ name: 'frog', type: 'string' }],
      },
      primaryType: 'Swamp',
      message: {
        frog: 'Robert',
      },
    }) 
  }
) 

handler

  • Type: (c: Context) => SignatureResponse

Handler function for the route.

import { Button, Frog, parseEther } from 'frog'
 
const app = new Frog({ title: 'Frog Frame' })
 
app.signature(
  '/sign',
  (c) => {
    return c.signTypedData({
      chainId: 'eip155:84532',
      types: {
        Swamp: [{ name: 'frog', type: 'string' }],
      },
      primaryType: 'Swamp',
      message: {
        frog: 'Robert',
      },
    })
  }
) 

Context Parameter

See the Context API.

signature Response

See the signature Response API.