Heat Wallet

Heat Wallet

  • User Manual
  • Developers

›App

User manual

  • Install the app
  • Getting Started
  • Create wallet
  • Import wallet
  • Spy on address
  • Paper/digital wallet
  • Receive crypto
  • Transfer crypto
  • Add currency
  • Balance staking

Developers

  • Developer info
  • Server

    • Add your coin
    • Plugin SDK
    • Fork SDK (non standard)
    • Network status
    • Network fee
    • Token discovery
    • Balance lookup
    • Event lookup
    • Event types
    • Utxo lookup
    • Transaction status
    • Alias lookup
    • Publickey lookup
    • Broadcast transaction

    App

    • Add your coin
    • Nodejs integrations
    • Wallet core (by Trust)

NodeJs Integrations

Integrations are slightly different for account based and utxo based protocols. Also differences exist for different types of blockchain features.

Privatekey, publickey, address

All integrations must be able to deal with private keys and public keys. These abilities are mandatory for each integration:

  1. Get public key from a private key
  2. Get address from a public key
  3. Validate an address

A very basic implementation for Bitcoin could look as follows (Note that Bitcoin is supported by wallet-core and this serves as an example only, other utxo based chains would use the pattern below). We indentify all our public methods with unique names so we can later invoke them through an event based messaging system.

module.exports = {
  /**
   * @param params {
   *   privateKey: string,
   *   network: string
   * }
   * @returns hex string
   */
  BITCOIN_GET_PUBLICKEY_FROM_PRIVATEKEY: function (params) {
    const { privateKey, network } = params
    return getPublicKeyFromPrivateKey(privateKey, network)
  },
  /**
   * @param params {
   *   publicKey: string,
   *   network: string
   * } params
   * @returns hex string
   */
  BITCOIN_GET_ADDRESS_FROM_PUBLICKEY: function (params) {
    const { publicKey, network } = params
    return getAddressFromPublicKey(publicKey, network)
  },
  /**
   * @param params {
   *   address: string,
   *   network: string
   * } params
   * @returns boolean
   */
  BITCOIN_IS_VALID_ADDRESS: function (params) {
    const { address, network } = params;
    return isValidAddress(address, network)
  }  
}

Blockchain protocol integrations can use standard Nodejs methods like a package.json to add external packages and use standard testing tools like mocha and chai to test their integrations. When ready and before this integration is added to Heat Wallet we run the code through metro bundler, this part right now has to be done by the Heat Wallet developers.

Note that return values from integration exported methods can either be standard values or Promises, if promises are returned these are dealt with transparantly.

Utxo

Utxo based protocols have a choice in which transactions types to support. The most basic form to support are 1 to 1 transactions meaning sending utxos to one address and the spare change is send back to your change address.

Heat wallet already provides coinselect logic so thats dealt with. If we include the required server plugin for your blockchain we automatically have all the utxo network infos which will be sufficient.

The part required by the integration developer is to create code that takes in a list of inputs and outputs and build and sign the transaction and return its raw bytes as hex string.

module.exports = {
  /**
   * @param params {
   *   inputs: Array<{
   *     vout: number,
   *     txId: string,
   *     privateKey: string,
   *     sequence: number,
   *     scriptSig: string,
   *     value: number,
   *   }>,
   *   outputs: Array<{
   *     address: string,
   *     value: number
   *   }>,
   *   network: string
   * }
   * @returns hex string
   */
  BITCOIN_CREATE_1_TO_1_TRANSACTION: function (params) {
    const { inputs, outputs, network } = params
    return create1to1Transaction(inputs, outputs, network)
  },
}

All standard nodejs development rules apply here.

Account based

Account based blockchains like Ethereum or Heat generally speaking support two types of transfers.

  1. Transfer native currency
  2. Transfer any type of token

We use the term token to describe any kind of unit that could be held by an address. One such example would be the native currency on a blockchain (each Bitcoin address has atleast the Bitcoin token). Other chains support more token types, Ethereum addresses for example can contain many different erc20 tokens.

Since account based blockchains have such different protocols and features its really upto integration developers which tweaks and features they wish to include. Heat blockchain for instance supports free form message attachments for transactions.

module.exports = {
  /**
   * @param params {
   *  key: string, 
   *  recipientAddress: string, 
   *  recipientPublicKey: string, 
   *  amount: string, 
   *  fee: string, 
   *  networkType: "prod" | "test", 
   *  message: string, 
   *  messageIsPrivate: boolean, 
   *  messageIsBinary: boolean
   * }
   * @returns hex string
   */
  HEAT_TRANSFER_HEAT: function (param) {
    const { key, recipientAddress, recipientPublicKey, amount, fee, networkType, message, messageIsPrivate, messageIsBinary } = param
    return transferHeat(key, recipientAddress, recipientPublicKey, amount, fee, networkType, message, messageIsPrivate, messageIsBinary)
  },
  /**
   * @param params {
   *  key: string, 
   *  recipientAddress: string, 
   *  recipientPublicKey: string, 
   *  amount: string, 
   *  fee: string, 
   *  networkType: "prod" | "test", 
   *  asset: string, 
   *  message: string, 
   *  messageIsPrivate: boolean, 
   *  messageIsBinary: boolean
   * }
   * @returns hex string
   */
  HEAT_TRANSFER_ASSET: function (param) {
    const { key, recipientAddress, recipientPublicKey, amount, fee, networkType, asset, message, messageIsPrivate, messageIsBinary } = param
    return transferAsset(key, recipientAddress, recipientPublicKey, amount, fee, networkType, asset, message, messageIsPrivate, messageIsBinary)
  },
}
Last updated on 8/25/2020
← Add your coinWallet core (by Trust) →
  • Privatekey, publickey, address
  • Account based
Heat Wallet
Docs
Install the appCreate your first walletImport an existing walletDevelopers
Community
Project ChatTwitter
Available here
Copyright © 2020 Heat Ledger