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
  • getVechainSignedTransaction()

Was this helpful?

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

Vechain

PreviousTezos (XTZ & XTZ_FA)NextNear (NEAR & Near Token)

Last updated 2 years ago

Was this helpful?

Sign Transaction

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

getVechainSignedTransaction()

Supported Coin Type

  • VECHAIN(VET)

  • VECHAIN Token(VECHAIN_ERC20)

Parameters

  • unsignedTx: unsigned hexadecimal tx

  • path: key path, wallet sign with that private key with a given key path (BIP32 ex) "m/44'/818'/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: vechain or vechain token's decimals.

Requirements

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

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

Useage

import { thorify } from 'thorify'
import BigNumber from 'bignumber.js'
const Web3 = require("web3");		// Recommend using require() instead of import here
const web3 = thorify(new Web3(), 'http://localhost:8669')

//https://github.com/vechain/thorify/blob/72988996cead74f9c73e38860c2e055ca35a108e/src/extend/accounts.ts#L12

let clauses = {
    from: recvAddress,
    to: toAddr,
    value: DcentWebConnector.unitConverter(amount, decimals).num.toString(),
    gas
}
let rawData = await web3.eth.accounts.signTransaction(clauses, VechainConfig.DummyKey)
rawData = rawData.rawTransaction.substr(0, rawData.rawTransaction.length - 134).slice(2)

let rawBuf = Buffer.from(rawData, 'hex')
let length  = rawData.length / 2
let adjustedRaw = ''  
let size = 0

if (rawBuf[0] < 0xc0) {
  adjustedRaw = null
}

if (rawBuf[0] <= 0xf7) {
  adjustedRaw = rawData.slice(2)
} else if (rawBuf[0] <= 0xff) {
  switch (rawBuf[0] - 0xf7) {
    case 1: 
      size = 1
      break
    case 2:
      size = 2
      break
    default:
      adjustedRaw = null
  }
  adjustedRaw = rawData.slice(2 + (size * 2))
} else {
  adjustedRaw = null  
}

length = adjustedRaw.length / 2
if (length < 56) {
  adjustedRaw = (0xc0 + length).toString(16) + adjustedRaw
} else if (length < 256) {  
  adjustedRaw = '0xf8' + (length).toString(16) + adjustedRaw
} else {
  adjustedRaw = '0xf9' + (length).toString(16) + adjustedRaw
}

const transactionJson = {
    coinType: DcentWebConnector.coinType.VECHAIN,
    sigHash: adjustedRaw.slice(2),
    path: `m/44'/818'/0'/0/0`,
    decimals, // 18
    fee: fee, 
    symbol: 'VET',
}

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

Returned response object

{
    "header": {
        "version": "1.0",
        "response_from": "vechain",
        "status": "success"
    },
    "body": {
        "command": "transaction",
        "parameter": {
            "signed_tx": "0x31aa13b5e04cb6fc6381ea0520bf7f6727ebdb6e96cd7ca8625bb3e3dd36cf0e2cee4ece13aa9f7ddc09ee10c74aa00af954201829d8016317f10f5a921dcc0d"
        }
    }
}
Vechain Docs