Skip to content

Latest commit

 

History

History
94 lines (68 loc) · 2.8 KB

web3j-component.adoc

File metadata and controls

94 lines (68 loc) · 2.8 KB

Web3j Ethereum Blockchain

Since Camel 2.22

Both producer and consumer are supported

The Ethereum blockchain component uses the web3j client API and allows you to interact with Ethereum compatible nodes such as:

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-web3j</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI Format

web3j://<local/remote host:port or local IPC path>[?options]

All URI options can also be set as exchange headers.

Examples

Listen for new mined blocks and send the block hash to a jms queue:

from("web3j://http://127.0.0.1:7545?operation=ETH_BLOCK_HASH_OBSERVABLE")
    .to("jms:queue:blocks");

Use the block hash code to retrieve the block and full transaction details:

from("jms:queue:blocks")
    .setHeader(BLOCK_HASH, body())
    .to("web3j://http://127.0.0.1:7545?operation=ETH_GET_BLOCK_BY_HASH&fullTransactionObjects=true");

Read the balance of an address at a specific block number:

from("direct:start")
    .to("web3j://http://127.0.0.1:7545?operation=ETH_GET_BALANCE&address=0xc8CDceCE5d006dAB638029EBCf6Dd666efF5A952&atBlock=10");

spring-boot:partial$starter.adoc