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
  • Get Public Key
  • Sign Transaction
  • Supported Transaction Types
  • getHederaSignedTransaction()

Was this helpful?

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

Hedera (HBAR & HTS)

PreviousEthereum & EVM compatibleNextdcent-provider

Last updated 2 years ago

Was this helpful?

Get Public Key

In order to get public key for Hedera Account, you can use getAddress() function.

If you use DcentCLIConnector.coinType.HEDERA as a coinType parameter for getAddress() function, you can get public key for the private key of the BIP44 path.

For more detail about getAddress(), please see the below section.

  • go to description

Sign Transaction

Supported Transaction Types

Transaction
Supported
Group

AccountCreateTransaction

O

Accounts

AccountUpdateTransaction

O

Accounts

TransferTransaction

O

Accounts

AccountDeleteTransaction

X

Accounts

AccountAllowanceApprovalTransaction

X

Accounts

AccountAllowanceAdjustTransaction

X

Accounts

TokenCreateTransaction

O

Token

TokenUpdateTransaction

O

Token

TokenDeleteTransaction

X

Token

TokenAssociateTransaction

O

Token

TokenDissociateTransaction

O

Token

TokenMintTransaction

O

Token

TokenBurnTransaction

O

Token

TokenFreezeTransaction

O

Token

TokenFeeScheduleUpdateTransaction

X

Token

TokenUnfreezeTransaction

O

Token

TokenGrantKycTransaction

X

Token

TokenRevokeKycTransaction

X

Token

TokenPauseTransaction

O

Token

TokenUnpauseTransaction

O

Token

TokenWipeTransaction

O

Token

For your reference, all transaction types for Hedera can be found here.

getHederaSignedTransaction()

Supported Coin Type

  • Hedera(HTS)

Parameters :

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

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

  • decimals: hedera or hts token's decimals.

Requirements:

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

Usage:

const _buf2hex = (buffer) => { // buffer is an ArrayBuffer
return Array.prototype.map.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('');
}
const client = HederaSDK.Client.forMainnet()
const nodeList = client._network.getNodeAccountIdsForExecute()
const validStart = Timestamp.generate()
const fromAccountId = AccountId.fromString('accountIdString')
const txId = new TransactionId(fromAccountId, validStart)
const tx = new HederaSDK.TransferTransaction()

// when you transfer hbar
tx.addHbarTransfer(fromAccountId, HederaSDK.Hbar.fromTinybars('-' + amountTinybar))
tx.addHbarTransfer('toAccountIdString', HederaSDK.Hbar.fromTinybars(amountTinybar))

// or you can transfer token like this.
tx.addTokenTransfer(contractAddress, fromAccountId, HederaSDK.Hbar.fromTinybars('-' + amountTinybar))
tx.addTokenTransfer(contractAddress, 'toAccountIdString', HederaSDK.Hbar.fromTinybars(amountTinybar))


tx.setNodeAccountIds([nodeList[nodeList.length - 1]])
tx.setTransactionId(txId)
tx.setTransactionMemo('')
tx.setMaxTransactionFee(fee)
tx.freezeWith(client)

const bodyBytes = tx._signedTransactions[0].bodyBytes
const unsignedTx = _buf2hex(bodyBytes)

const transactionJson = {
    unsignedTx: unsignedTx,
    path: `m/44'/3030'/0'`,
    symobl: HBAR,
    decimals: 8,
}

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

Returned response object:

{
    "header": {
        "version": "1.0",
        "response_from": "hedera",
        "status": "success"
    },
    "body": {
        "command": "transaction",
        "parameter": {
            "signed_tx": "0x31aa13b5e04cb6fc6381ea0520bf7f6727ebdb6e96cd7ca8625bb3e3dd36cf0e2cee4ece13aa9f7ddc09ee10c74aa00af954201829d8016317f10f5a921dcc0d",
            "pubkey": "0x9a5c753d02038e512c06867556324b37181c9c1fc19c21c27752c520e8f0d822"
        }
    }
}

unsignedTx: unsigned hexadecimal tx

This feature is tested with v2.8.0

Get Address API
https://docs.hedera.com/guides/docs/sdks/transactions
Hedera Docs
Hedera JavaScript SDK