D'CENT developer guide
Official siteUser GuideBlogTwitter
  • Introduction
  • How to Connect Your DApp to D’CENT Mobile App
  • In-app browser (dapp browser)
    • Getting Started
    • EVM compatible networks
    • Klaytn network
    • Tron network
  • Dynamic Link
    • Dynamic Link to In-app Browser
    • EIP-681 : Transaction/Payment Request
  • D'CENT WalletConnect (DWC)
    • Introduction
    • Packages
    • D'CENT WalletConnect
    • Test Environment
    • WalletConnect monorepo
  • Collectibles
    • NFT list on Collectibles tab
  • D'CENT biometric wallet for PC
    • D'CENT SDK for PC Environment
    • dcent-web-connector
      • Configurations
      • Device & Accounts Info.
      • Address & XPUB
      • Ethereum & EVM compatible
      • Klaytn
      • Bitcoin
      • XRPL (XRP Ledger)
      • Hedera (HBAR & HTS)
      • Tron (TRX & TRC20)
      • Stellar
      • Tezos (XTZ & XTZ_FA)
      • Vechain
      • Near (NEAR & Near Token)
      • Havah
      • Polkadot
      • Polkadot Parachain
      • Cosmos & Cosmos compatible network
      • Algorand
    • dcent-cli-connector
      • Configurations
      • Device & Accounts Info.
      • Address & XPUB
      • Ethereum & EVM compatible
      • Hedera (HBAR & HTS)
    • dcent-provider
  • D'CENT BIOMETRIC WALLET FOR Mobile
    • D'CENT SDK for Mobile Environment
    • dcent-biometric-sdk-android
      • Setup
      • Initialize
      • Device & Accrouts Info
      • Address & XPUB
      • Bitcoin
      • Ethereum & EVM compatible
      • Klaytn
      • XRPL
      • Binance
      • Stellar
      • Tron
      • Cardano
      • Hedera
      • Stacks
      • Solana
      • Conflux
      • Polkadot
      • Cosmos
      • Tezos
      • Vechain
      • Near
      • Havah
      • Algorand
    • dcent-biometric-sdk-ios
      • Setup
      • Initialize
      • Device & Accrouts Info
      • Address & XPUB
      • Bitcoin
      • Ethereum & EVM compatible
      • Klaytn
      • XRPL
      • Binance
      • Stellar
      • Tron
      • Cardano
      • Hedera
      • Stacks
      • Solana
      • Conflux
      • Polkadot
      • Cosmos
      • Tezos
      • Vechain
      • Near
      • Havah
      • Algorand
  • D'CENT Integrated Packages
    • Web3Modal
    • web3-onboard
  • Misc.
    • Logo & Brand Guideline
Powered by GitBook
On this page
  • Sign Transaction
  • getHavahSignedTransaction()

Was this helpful?

  1. D'CENT biometric wallet for PC
  2. dcent-web-connector

Havah

PreviousNear (NEAR & Near Token)NextPolkadot

Last updated 2 years ago

Was this helpful?

Sign Transaction

The D'CENT Web SDK provides functions for signing transaction of coins.

getHavahSignedTransaction()

Supported Coin Type

  • HAVAH(HTS)

  • HAVAH Token(HSP20)

Parameters

  • unsignedTx: unsigned hexadecimal tx

  • path: key path, wallet sign with that private key with a given key path (BIP32 ex) "m/44'/858'/0'/0/0").

  • fee: fee, It is fee that wallet displays on the screen.

  • symbol: symbol, It is a symbol that the wallet displays on the screen.

  • decimals: havah or havah token's decimals.

Requirements

  • D'CENT Bridge version 1.5.0 or higher is required.

  • D'CENT Biometric Wallet version 2.26.0 or higher is required.

Useage

import IconService from 'icon-sdk-js'

const { IconBuilder, IconAmount, IconConverter, IconUtil } = IconService

const httpProvider = new HttpProvider('https://ctz.solidwallet.io/api/v3');
const iconService = new IconService(httpProvider);
// networkId of node 1:mainnet, 2~:etc
const networkId = new BigNumber("3"); // input node’s networkld
const version = new BigNumber("3"); // version

// Recommended icx transfer step limit :
// use 'default' step cost in the response of getStepCosts API
const stepLimit = await this.getDefaultStepCost(); // Please refer to the above description.

// Timestamp is used to prevent the identical transactions. Only current time is required (Standard unit : us)
// If the timestamp is considerably different from the current time, the transaction will be rejected.
const timestamp = (new Date()).getTime() * 1000;
const value = IconAmount.of(Number(amount), IconAmount.Unit.ICX).toLoop()

// Enter transaction information
const { IcxTransactionBuilder } = IconBuilder
const icxTransactionBuilder = new IcxTransactionBuilder();
const transaction = icxTransactionBuilder
  .nid(networkId)
  .from(walletAddress)
  .to(MockData.WALLET_ADDRESS_2)
  .value(value)
  .version(version)
  .stepLimit(stepLimit)
  .timestamp(timestamp)
  .nonce(IconConverter.toBigNumber(1))
  .build();

const rawData = Buffer.from(IconUtil.generateHashKey(IconConverter.toRawTransaction(tx))).toString('hex')
const sigHash = rawData

const transactionJson = {
    coinType: DcentWebConnector.coinType.HAVAH,
    sigHash: sigHash,
    path: `m/44'/858'/0'/0/0`,
    decimals: IconAmount.Unit.ICX,
    fee,
    symbol: 'HVH',
}

var result
try {
    result = await DcentWebConnector.getHavahSignedTransaction(transactionJson);  
} catch (e) {
    console.log(e)
    result = e
}

Returned response object

{
    "header": {
        "version": "1.0",
        "response_from": "havah",
        "status": "success"
    },
    "body": {
        "command": "transaction",
        "parameter": {
            "signed_tx": "0x31aa13b5e04cb6fc6381ea0520bf7f6727ebdb6e96cd7ca8625bb3e3dd36cf0e2cee4ece13aa9f7ddc09ee10c74aa00af954201829d8016317f10f5a921dcc0d"
        }
    }
}
Hevah(ICON) Docs