MYKEY Docs
中文English
English
English
  • Introduction
  • Sign in with MYKEY
    • Verify signature at backend server
    • More detailed tech and process of MYKEY login
  • Integrate with MYKEY
    • Multiple ways to integration with MYKEY
    • Mobile Dapp with H5 pages
      • ETH
      • EOS
      • JS Extensions
    • Integration via MYKEY Android SDK
      • Preconditions
      • Initiate SDK
      • Authorize
      • Sign
      • Transfer
      • Call contracts
    • Integration via MYKEY iOS SDK
      • Preconditions
      • Initiate SDK
      • Authorize
      • Sign
      • Transfer
      • Call contracts
    • Web application with scanning qrcode
    • SimpleWallet Protocol Compatible
    • Deeplink Protocol
  • Dive into MYKEY
    • Dive into MYKEY account
    • Classes and methods
      • Android Classes
      • iOS Classes
    • Error Code
    • Identify MYKEY deposit transaction
      • ETH deposit
      • EOS deposit
    • MYKEY Whitepaper
  • KEY ID
    • KEYID ETH Contracts introduction
      • Account Module
      • Account Storage Module
      • Logic Management Module
      • Logic Module
    • Account recovery mechanism
    • KEYID contract upgrade process
    • KEYID contract upgrade records
      • ETH
        • KEY ID Ethereum Contracts Upgrade Pending Time Adjustment
        • KEY ID Ethereum logic contract module upgrade announcement
        • KEY ID Ethereum Contracts Upgrade Pending Time Adjustment
        • KEY ID Ethereum AccountLogic/DualsigsLogic Contracts Upgrade
        • KEY ID Ethereum DappLogic Contract Upgrade
  • Development Resources
    • Ethereum
    • EOS
  • Join Us
    • DApp submit
    • Developers Community
Powered by GitBook
On this page
  • Compatible with Scatter
  • Login
  • Verify the signature from MYKEY

Was this helpful?

  1. Integrate with MYKEY
  2. Mobile Dapp with H5 pages

EOS

PreviousETHNextJS Extensions

Last updated 4 years ago

Was this helpful?

Compatible with Scatter

MYKEY is compatible with Scatter protocol. You can develop dapp with Scatter protocol, and access it with MYKEY's default browser.

You can also refer below link to get more details about Scatter protocol:

Login

Use scatter.connect method, then login method to get user account information.

import ScatterJS from "@scatterjs/core";

ScatterJS.connect("My DAPP", { network }).then(connected => {
  if (!connected) return alert("no scatter");

  const eos = ScatterJS.eos(network, Api, { rpc });
  this.setState({ eos });

  ScatterJS.login().then(id => {
    if (!id) return alert("no identity");
    const account = ScatterJS.account("eos");
    this.setState({ account }, this.getVote);
  });
});

Verify the signature from MYKEY

The Reserved Key can be queried through the keydata table of the mykeymanager smart contract. When querying, the specified range is the MYKEY account and the index is 3.

/**
 * Get ReservedKey in mykey account which is for other actions without specific operation keys, details in
 * https://docs.mykey.org/v/English/dive-into-mykey/mykey-on-eos#mykey-account-structure
 * @param  {String}  name account name
 * @return {String}      ReservedKey/the 3rd Operation Key
 */
async getReservedKey(name) {
	const mgrcontract = await this.getMykeyMgr(name)
    const mykey_signkey_index = 3
    const keydata = await this.eosJsonRpc.get_table_rows({json:true, code:mgrcontract, scope:name, table:'keydata', lower_bound: mykey_signkey_index, limit:1})
    if(!keydata) return '';
    return keydata.rows[0].key.pubkey;
}

/**
 * Verify signed data
 * Parameters
 *  signature (string | Buffer) buffer or hex string
 *  data (string | Buffer)
 *  pubkey (pubkey | PublicKey)
 *  encoding (optional, default 'utf8')
 *  hashData boolean sha256 hash data before verify (optional, default true)
 */
ecc.verify(signature, data, pubkey) === true

is different with other EOS account, if dapp verify signature in their server side, should use the ReservedKey, more details see this

https://get-scatter.com/developers/settingupforwebapps
MYKEY account structure
Document.