Useful tips for building a dApp by using Connex

This article will help you to understand how to use connex to build a dApp and also how it interacts with the user, application, and Sync2.


  1. Create a testnet wallet

    1. Download Sync2 here

    2. Launch Sync2

    3. Sync2 - setup

  2. Claim testnet token

Learn & play


The ticker is a concept that describes chain increment. When there is a new block added to the chain, the ticker will be triggered. This API will create a ticker that has a function that creates a Promise that will resolve when a new block is truly added, please be advised that it never rejects.

📖 Tips

  • progress: A number [0-1] indicates the syncing progress of the currently connected node

ref: connex API - create a ticker


Account visitor is a bunch of APIs to get account details and interact with account methods.

📖 Tips

  • balance: hex form of VET balance in unit wei

  • energy: hex form of VTHO balance in unit wei

  • hasCode: when it equal to true, it means that its a smart contract

ref: connex API - account visitor


Transaction visitor is a bunch of APIs to get transaction details.

📖 Tips

Transaction receipt

  • reverted: Several reasons can cause the transaction to revert. It means that the transaction data is passed through to a virtual machine(aka. VM) but not able to process. The most common reasons are insufficient balance and smart contract not able to execute data.

  • gasPayer: the address which paid the transaction fee. It is an important factor to determine the transaction is whether using fee delegation or not. If the transaction is paid by another address, the txOrigin and gasPayer will be different..

  • txOrigin: the address which signed the transaction

ref: connex API - transaction visitor


It allows you to filter transfer and event logs on the blockchain. The filter usually works with Connex.thor.account, either creates a filter from an event or packs criteria and then assembles several criteria and sets them to a filter.

📖 Tips

  • criteria: is a set of an array which contain a event.criteria or transfer.criteria. The items in the criteria array will be combined by OR operator to filter the events: example: [{"ConA": "A"}, {"ConB": "B", "ConC": "C"}] is 'ConA=A OR (ConB=B AND ConC=C)'

  • filterRange: Filtering a specific time frame transfer or event logs by setting block number or timestamp in second to the filter

• transfer

Filter VET transfer by setting the criteria to txOrigin,sender, and recipient.In addition, set the filterRange of filter to determine the transfer flog in the specific period

• event

Filter event by setting criteria base on the contract methods(Contract ABI).

ref: connex API - filter


In some cases, the application may not need the ability to access the entire blockchain. You can just create connex.vendor module instead of connex.thor module.connex.vendor is a way that allows dapps to interact with a user such as signing a certificate or transaction.

Certificate: connex.vendor.sign

The certificate is a message signing-based mechanism that can easily request the user's identification(address) or user to agree to the agreements.

ref: connex API - certificate signing service

Transaction: connex.vendor.sign

Signing a transaction is the most common interaction between dApp and user.A transaction may contains one more multiple clauses(operation) that requesting the user to confirm(sign) the transaction.

📖 Tips

  • Transaction can contains multiple clauses and each clause contains three majors content: to ,value and data.

  • Provide a brief comment to the transaction or a clause to help the user to understand

  • Provide a link to reveal transaction-related information, the link will be used for connex to assemble a callback url by replacing the placeholder {txid} by Transaction ID

ref: connex API - transaction signing service


1. Buy an item with user login

2. Token transfer

3. Buy me a coffee

4. Address avatar

Address avatar is generated by Picasso a general purpose deterministic identity icon library in svg format

5. Sign tx and check receipt

6. Estimate the transaction fee

GasPriceCoef can be adjust by the user, thus, the result of the transaction fee is the minimum cost of the transaction.


  1. Need to know the Base gas price from params contract

  2. According to transaction calculation

    • we need to calculate the intrinsic gas

    • we need to know the vm gasUsed (aka. virtual machine execution cost)

Step 1: Get base gas price

Step 2: Get intrinsic gas

Step 3: Get vm gas used

7. Enforce signer

Last updated