Hedera Consensus Service API

Quickstart Guide

A consensus service for any app

The Hedera Consensus Service was built for any application that requires high-throughput, trusted timestamps, and fast finality — track assets across a supply chain, create auditable logs of events in an advertising platform, or even use it as a trusted ordering service for an application built using Hyperledger Fabric. It's all made possible thanks to the native speed, security, and fair ordering guarantees of the hashgraph consensus algorithm on the Hedera public network.

Consensus without compromise

Build natively
Create applications that are as fast as native services, because they take advantage of the native speed of the hashgraph consensus algorithm.
Amplify trust
Bring the full trust of the Hedera ledger to private networks, even if the members of the private network aren't trusted: the trusted nodes in Hedera amplify the trust of the private network.
Guarantee order
The Consensus Service uses hashgraph to put transactions into a consensus order, with fair timestamps, along with state proofs that guarantee it is correct.

Building with Hedera Consensus Service

Advertising

“Using Hedera Consensus Service, advertisers can be more confident that their data is both accurate and tamper-proof, aiding in the fight to reduce ad-fraud and recover the billions of dollars lost each year in wasted ad spend.”

Financial Services

“There’s tremendous value in combining the trustless consensus of a public network with the privacy of a permissioned network for all our sensitive transactions and data."

Gaming

“Hedera Consensus Service offers high-throughput and public verifiability of in-game events that the decentralized gaming industry has been waiting for.”

Supply Chain

“We’re able to securely process data at scale, in our customer's enterprise supply chains, without the drawbacks of using smart contracts.”

Create a topic, send a message

Use the Hedera Consensus Service API to start building applications which take advantage of the high-throughput, fair ordering, and fast finality of Hedera Hashgraph.

Function

Create topic
  • Create topic
  • Submit Message
  • Subscribe to Mirror

const { ConsensusTopicCreateTransaction } = require("@hashgraph/sdk");


const transactionId = await  new ConsensusTopicCreateTransaction()

     .setMessage("Hello Hedera Consensus Service!")

     .setMaxTransactionFee( new Hbar(10)) 

     .execute(HederaClient);


const transactionReceipt = await transactionId.getReceipt(HederaClient);


console.log(transactionReceipt);

const { ConsensusSubmitMessage } = require("@hashgraph/sdk");


const transactionId = await  new ConsensusSubmitMessage()

     .setMessage("Hello decentralized messaging on Hedera Hashgraph!")

     .setMaxTransactionFee( new Hbar(1)) 

     .execute(HederaClient);


const transactionReceipt = await transactionId.getReceipt(HederaClient);


console.log(transactionReceipt);

const { MirrorConsensusTopicQuery } = require("@hashgraph/sdk");


new MirrorConensusTopicQuery()

    .setTopicId("0.0.123456789")

    .subscribe(MirrorNode, (message) => {

         console.log("Received message from our mirror node subscription:", message.toString());

         console.log("timestamp:", message.getTimestamp());

         console.log("runningHash:", message.getRunningHash());

         console.log("topicId:", message.getTopicId());

         console.log("sequenceNumber:", message.getSequenceNumber());

});

Log the truth

Even if an application runs on a network that is not well trusted, that trust can be amplified by relying on the trusted Hedera ledger for the consensus ordering and timestamps. Track an item through a supply chain, provide a transparent bidding system, or process transactions, with auditable logs of the history.

1: Create topic

A topic is created to manage the stream of messages for one application, such as a market where people bid on products.

2: Send

When an event happens – like a bid – it can be sent as an encrypted message to the topic.

3: Process

All of the messages are put into consensus order by the Hedera mainnet. A mirrornet can then send the messages for a particular topic to the application for processing.

4: Audit

When an audit needs to be conducted, previous messages can be checked, along with a state proof that ensures they have not been falsified.

"There are a number of challenges in using traditional ordering services for decentralized applications. By exposing this capability, Hedera is making a meaningful contribution to furthering the capabilities of distributed networks."

Bryan Gross
Principal Product Manager

Consensus Service API and network features

Topic Management

Topics make it simple to organize transactions, so each application only receives the messages it needs.

Consensus Order

Messages are put into consensus order and given a timestamp by the Hedera network, with cryptographic proofs, so they are as trustworthy as the full Hedera network.

Audit log

Messages are cryptographically tied together with a running hash to provide an auditable, tamper-proof log of history.

Scalable transactions

Message processing and storage are kept outside the Hedera network. This allows higher speed and scalability.

Low Fees

The high speed and good scaling ensure low, micropayment fees on par with Hedera Cryptocurrency.

Historical Data

The Hedera Consensus Service ensures speed and security are kept on the ledger while storage is kept off-ledger. Choose to keep everything, nothing, or anything in between.

Explore Hedera Consensus Service

From ideation to building your application, check out these Hedera Consensus Service resources to help you along your journey.

A network for decentralized applications

Explore other Hedera network services to run powerful smart contracts and manage files.

Cryptocurrency

ENABLE FAST, LOW FEE PAYMENTS

Cryptocurrency payments allow you to transact without intermediaries to lower costs and make complex payments simple with code.
File Service

Sign and verify files

Create and manage files, with guaranteed visibility, acting as a revocation service for credentials. Hedera uniquely enables the ability to prove GDPR compliance with controlled mutability.
Smart Contract

TOKENIZE AND EXCHANGE ASSETS

The tokenized economy will change how we define ownership. Use the Solidity language to create assets, perform atomic swaps, or interact with outside oracles.

Ready to start building?

Get started with Hedera Consensus Service