Skip to content
Hash.js is a collection of standard functions that allow you to interact with a Hedera Hashgraph wallet without giving complete access to the public/private key pairs of an account.
JavaScript HTML CSS
Branch: master
Clone or download
Latest commit a591ea1 Jan 21, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
css added account check function Sep 26, 2019
js added account check function Sep 26, 2019
.gitignore
README.md v1.4.1 Jan 21, 2020
index.html added account check function Sep 26, 2019

README.md

Hash.js

Hash.js is a micropayment service javascript embeddable library. You can trigger micropayment transactions using the chrome extension through hosting the widget yourself by compiling it locally or use our cdn’ed widget.

Hash.js is an Open Source Project, see the Contributing section to find out what this means.

Important Notes for Existing Users

V1.4.1 implements a few key fixes for smart contract developers.

Latest Extension is available at the chrome store

Installation

What do you need to get started?

Make sure you sign up on portal.hedera.com and download the Hedera Wallet Chrome Extension. Configure it with your own wallet and make sure it’s funded with HBAR.

In order to make payments from your domain you will also have to set up automatic payment values or you will get an “insufficient-amount” error.

Web Testing:

You can test directly by pulling this repo. The main.js file contains testing functions you can work with.

Table of Contents

enable

Triggers a prompt on website for composer extension connect guide

Parameters

Examples

hash.enable((err,res)=>{
  if(err){
      //error case
      console.log('Error:::',err);
  }else{
      //success case
      console.log('Success:::',res);
  }
});
// triggers a prompt window on your website

Returns function callback

triggerCryptoTransfer

Triggers a Cryptotransfer prompt from composer extension

Parameters

  • data object An object containing
    • data.contractid string contract Id can be of account id type('0.0.1234') or domain name type ('mydomain.hh')
    • data.memo string short message specifying the purpose or message relating to the call
    • data.extensionid string (optional) - extension id of composer
    • data.recipientlist string to addresses of recipients as string of object
    • data.contentid string (optional)
    • data.type string (optional)
    • data.redirect string (optional)
  • cb function

Examples

hash.triggerCryptoTransfer(data, (err,res)=>{
  if(err){
      //error case
      console.log('Error:::',err);
  }else{
      //success case
      console.log('Success:::',res);
  }
});
// tiggers cryptotransfer extension prompt

Returns function callback

triggerSmartContract

Triggers a Smart Contract call prompt from composer extension

Parameters

  • data object An object containing
    • data.contractid string contract Id can be of account id type('0.0.1234') or domain name type ('mydomain.hh')
    • data.memo string short message specifying the purpose or message relating to the call
    • data.params string (optional) - string of Array which contains parameters of contract function to be executed
    • data.abi string determines the function call and provides the inputs and outputs for the specific function you’re trying to call
    • data.extensionid string (optional) - extension id of composer
    • data.gasfee number cost of transaction fee(tinybars) needed for call
    • data.transactionfee number cost of transaction fee(tinybars) needed for call
    • data.amount number (optional)
  • cb function

Examples

hash.triggerSmartContract(data, (err,res)=>{
  if(err){
      //error case
      console.log('Error:::',err);
  }else{
      //success case
      console.log('Success:::',res);
  }
});
// tiggers smart contract call extension prompt

Returns function callback

deploySmartContract

Triggers a Smart Contract Deploy prompt from composer extension

Parameters

  • data object An object containing
    • data.fileid string (alternative to bytecode) - id of the file if created already
    • data.memo string short message specifying the purpose or message relating to the call
    • data.params string (optional) - string of Array which contains parameters of contract function to be executed
    • data.abi string determines the function call and provides the inputs and outputs for the specific function you’re trying to call
    • data.bytecode string (alternative to fileid) - low-level code version of actual file
    • data.extensionid string (optional) - extension id of composer
    • data.gasfee number cost of transaction fee(tinybars) needed for call
    • data.transactionfee number cost of transaction fee(tinybars) needed for call
    • data.expirationTime number (optional) expiry time of contract in milliseconds (optional, default 7890000000)
    • data.amount number (optional)
  • cb function

Examples

hash.deploySmartContract(data, (err,res)=>{
  if(err){
      //error case
      console.log('Error:::',err);
  }else{
      //success case
      console.log('Success:::',res);
  }
});
// tiggers smart contract deploy extension prompt

Returns function callback

triggerFileCreate

Stores a file and creates a corresponding fileId for the same

Parameters

  • data object An object containing
    • data.memo string short message specifying the purpose or message relating to the call
    • data.fileContent string contents of the file
    • data.fileSize-null number size of file in bytes
    • data.extensionid string (optional) - extension id of composer
    • data.transactionfee number cost of transaction fee(tinybars) needed for call
    • data.expirationTime number (optional) expiry time of contract in milliseconds (optional, default 7890000000)
  • cb function

Examples

hash.triggerFileCreate(data, (err,res)=>{
  if(err){
      //error case
      console.log('Error:::',err);
  }else{
      //success case
      console.log('Success:::',res);
  }
});
// tiggers create file extension prompt

Returns function callback

triggerFileRetrieve

Retrieves a file(fileContents) corresponding to a fileId

Parameters

  • data object An object containing
    • data.memo string short message specifying the purpose or message relating to the call
    • data.fileid string id of the file, to retrieve the fileContentses
    • data.transactionfee number cost of transaction fee(tinybars) needed for call
  • cb function

Examples

hash.triggerFileRetrieve(data, (err,res)=>{
  if(err){
      //error case
      console.log('Error:::',err);
  }else{
      //success case
      //{
      //   res:{
      //          contents:{"0":84,"1":104,"2":105,"3":115,"4":32,"5":105,"6":115,"7":32,"8":97,"9":32,"10":116,"11":101,"12":115,"13":116,"14":32,"15":102,"16":105,"17":108,"18":101,"19":44,"20":32,"21":119,"22":104,"23":105,"24":99,"25":104,"26":32,"27":99,"28":111,"29":110,"30":116,"31":97,"32":105,"33":110,"34":115,"35":32,"36":115,"37":97,"38":109,"39":112,"40":108,"41":101,"42":32,"43":100,"44":97,"45":116,"46":97},
      //          contentAsString:"This is a test file, which contains sample data",
      //          walletAccount":"0.0.17210"
      //      }
      //}
      console.log('Success:::',res);
  }
});
// tiggers create file extension prompt

Returns function callback

triggerCheckBalance

Checks balance of current account selected in composer extension or checks the balance of the given account id

Parameters

  • accountID string account id in accountID format("0.0.12345")
  • cb function

Examples

hash.triggerCheckBalance("0.0.12345", (err,res)=>{
  if(err){
      //error case
      console.log('Error:::',err);
  }else{
      //success case
      // {
      //   res:{
      //           balance:"2363161",
      //           currentAccount:"0.0.12345",
      //           currentNetwork:"mainnet"
      //       }
      // }
      console.log('Success:::',res);
  }
});

Returns function callback

ethAddressToAccountId

Converts hexadecimal eth address to account id type('0.0.1234')

Parameters

  • ethAddress string an hexadecimal value

Examples

hash.ethAddressToAccountId("0000000000000000000000000000000000003039);
//returns "0.0.12345"

accountIdToEthAddress

Converts account id type('0.0.1234') to hexadecimal eth address

Parameters

  • accountId
  • ethAddress string an hexadecimal value

Examples

hash.accountIdToEthAddress("0.0.12345");

Returns string "0000000000000000000000000000000000003039"

Browser

You can learn more at api.hashingsystems.com

Contributing

You're welcome to contribute code on here. Fork and create a detailed pull request.

For more info you can chat with us at https://hashingsystems.com

License

See LICENSE for details. Hashing Systems © 2019

You can’t perform that action at this time.