ThunderCore
ThunderCoreThunderCore Bridge
  • ⚡Hello world
  • Developer Program
  • Network Details
    • ThunderCore Mainnet
    • ThunderCore Testnet
    • Token List
    • Smart Contract Services
    • Full Node Deployment
  • Develop on ThunderCore
    • Migrate from Ethereum
    • Using Foundry
    • Using Hardhat
    • Using Remix
    • Using Truffle
    • Deploy TT20
    • Deploy a DApp
    • Deploy a NFT
  • Develop on TT Wallet
    • DApp Submission
    • Deeplinking
    • Signing Messages
    • Ethereum Provider API
    • Token Listing
    • Advertising with TT Wallet
      • Logo size submission guideline
      • Promotional Package
      • How we help developers
    • Developer Build - TT Wallet (Android)
  • FAQs
  • Product / Protocol
    • Wallets
      • MetaMask
        • Create a MetaMask Wallet
        • Create multiple accounts
      • TT Wallet
    • ThunderCore Bridge
      • Architecture
      • Ethereum <> ThunderCore
      • BNB chain <> ThunderCore
      • Interact with ThunderCore Bridge
  • Tool
    • Game Development
      • MetaFab
    • DApp Development
      • Faucet
      • Random Number Generator
      • Oracles
      • Referral Library
      • TTSwap Resources
      • Wrapped TT Addresses
      • Multicall
      • Subgraph
      • Auth Service
      • Wallet Service
      • Node Service
Powered by GitBook
On this page
  • Summary
  • Signing Data with TT Wallet
  • Sign Typed Data v3 and Sign Typed Data v4
  • Personal_sign
  1. Develop on TT Wallet

Signing Messages

Last updated 1 year ago

Summary

In the EVM-compatible blockchain world, signing messages can be used to prove ownership of a specific address. When signing a message with our private key, we don’t require interacting with the ThunderCore network. It can be implemented completely offline. Hence the purpose of this section is to describe how to use the signing messages in TT Wallet.

Signing Data with TT Wallet

Now TT Wallet currently support three signing methods:

  • eth_signTypedData_v3

  • eth_signTypedData_v4

  • personal_sign

If you’d like to know the differences between these signature methods, you can .

Sign Typed Data v3 and Sign Typed Data v4

signTypedData_v3 and signTypedData_v4 currently represent the latest version of the , making it the most secure methods and cheap-to-verify messages on-chain or off-chain.

Here's an example how it works:

const msgParams = {
  types: {
    EIP712Domain: [
      { name: "name", type: "string" },
      { name: "version", type: "string" },
      { name: "chainId", type: "uint256" },
      { name: "verifyingContract", type: "address" },
    ],
    Person: [
      { name: "name", type: "string" },
      { name: "wallet", type: "address" },
    ],
    Mail: [
      { name: "from", type: "Person" },
      { name: "to", type: "Person" },
      { name: "contents", type: "string" },
    ],
  },
  primaryType: "Mail",
  domain: {
    name: "Ether Mail",
    version: "1",
    chainId: 1,
    verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
  },
  message: {
    from: { name: "Cow", wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" },
    to: { name: "Bob", wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" },
    contents: "Hello, Bob!",
  },
};

const from = window.ethereum.selectedAddress;

const params = [from, JSON.stringify(msgParams)];
const method = "eth_signTypedData_v3"; // Or eth_signTypedData_v4

window.ethereum.sendAsync(
  {
    method,
    params,
    from,
  },
  (err, result) => {
    if (err) return console.dir(err);
    if (result.error) {
      alert(result.error.message);
    }
    if (result.result) {
      console.log("TYPED SIGNED:" + JSON.stringify(result.result));
    }
  }
);

Personal_sign

Most of the code is the same as above, here are the differences:

const params = [JSON.stringify(msgParams), from];

const method = "personal_sign";

personal_sign is similar to eth_sign which is specified by , but has better security, see for details.

visit this website
EIP-721 spec
the Ethereum RPCs#eth_sign
Technical Reference