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
  • ThunderCore RPC Methods
  • Interface
  • eth_requestAccounts
  • Other RPC Methods
  • eth_decrypt
  • eth_getEncryptionPublicKey
  1. Develop on TT Wallet

Ethereum Provider API

Last updated 1 year ago

Summary

TT Wallet injects a global API into site visited by its users at window.ethereum.

Considering the massive adoption, this API specification borrows heavily from Metamask's documents. So Dapp developers can easily request users's ThunderCore's accounts, read data from blockchians, and prompt the users to sign data and send transactions.

The Ethereum JavaScript provider API is specified by .

ThunderCore RPC Methods

TT Wallet uses the window.ethereum.request(args) method to wrap an RPC Call. Please see the .

Important methods from this API include:

  • eth_acccounts

  • eth_requestAccounts

  • eth_call

  • eth_getBalance

  • eth_sendTransaction

  • eth_decrypt

  • eth_getEncryptionPublicKey

  • eth_sign

  • personal_sign

  • eth_signTypedData

  • eth_signTypedData_v3

  • eth_signTypedData_v4

  • personal_ecRecover

Interface

interface RequestArguments {
    method: string;
    params: unknown[] | object;
};

window.ethereum.request(args: RequestArguments): Promise<unknown>;

eth_requestAccounts

Returns

string[] - An array of a single, hexadecimal ThunderCore address string.

Description

Requests that the user provides an ThunderCore address to be identified by. Returns a Promise that resolves to an array of a single ThunderCore address string.

Example

window.ethereum
  .request({ method: "eth_requestAccounts" })
  .then((accounts) => {})
  .catch((error) => {});

Other RPC Methods

eth_decrypt

Parameters

  • Array

    1. string - An encrypted message.

    2. string - The address of the ThunderCore account that can decrypt the message.

Description

Requests that TT Wallet decrypts the given encrypted message. The message must have been encrypted using the public encryption key of the given ThunderCore address. Returns a Promise that resolves to the decrypted message, or rejects if the decryption attempt fails.

Example

window.ethereum
  .request({
    method: "eth_decrypt",
    params: [encryptedMessage, accounts[0]],
  })
  .then((decryptedMessage) => {})
  .catch((error) => {});

eth_getEncryptionPublicKey

Parameters

  • Array

    1. string - The address of the ThunderCore account whose encryption key should be retrieved.

Returns

string - The public encryption key of the specified ThunderCore account.

Description

Requests that the user shares their public encryption key. Returns a Promise that resolve to the public encryption key, or rejects if the user denied the request.

Example

window.ethereum
  .request({
    method: "eth_getEncryptionPublicKey",
    params: [accounts[0]],
  })
  .then((result) => {})
  .catch((error) => {});

The public key is computed from entropy associated with the specified user account, using the implementation of the X25519_XSalsa20_Poly1305 algorithm.

EIP-1193
Ethereum wiki
nacl