DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • Automated Multi-Repo IBM App Connect Enterprise BAR Builds
  • Comparing Cloud Hosting vs. Self Hosting
  • Designing a New Framework for Ephemeral Resources
  • gRPC Basics
  1. DZone
  2. Coding
  3. Frameworks
  4. Spring Boot and web3j: Easy Microservices for Ethereum Blockchain

Spring Boot and web3j: Easy Microservices for Ethereum Blockchain

web3j seamlessly integrates with Spring Frameworks. Simply create a new Spring Boot app, add the starter to your configuration, and create a service with web3j.

Conor Svensson user avatar by
Conor Svensson
·
Apr. 06, 17 · Tutorial
Like (8)
Save
Tweet
Share
11.36K Views

Join the DZone community and get the full member experience.

Join For Free

web3j now seamlessly integrates with the Spring Framework thanks to the web3j Spring Boot Starter.

Using Spring Boot, it's trivial to create production-ready services using web3j to work with the Ethereum blockchain.

Start by creating a new Spring Boot application. Then add the web3j-spring-boot-starter to your Gradle or Maven configuration:

dependencies {
    compile 'org.web3j:web3j-spring-boot-starter:1.0.0'
    ...
}

Now, create a service using web3j, and Spring will create and configure the web3j instance for you!

@Service
public class Web3jSampleService {
 
    @Autowired
    private Web3j web3j;
 
    public String getClientVersion() throws IOException {
        Web3ClientVersion web3ClientVersion = web3j.web3ClientVersion().send();
        return web3ClientVersion.getWeb3ClientVersion();
    }
}

The default HTTP endpoint of your Ethereum client is used (http://localhost:8545). However, you can easily change this in your application properties file.

# An infura endpoint
web3j.client-address = https://morden.infura.io/<your token id>
 
# Or, an IPC endpoing
web3j.client-address = /path/to/file.ipc

Code for this example is available here. For further information on it, check out the web3j project home page and the spring-boot-starter project.

Spring Framework Spring Boot Ethereum Blockchain microservice

Published at DZone with permission of Conor Svensson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Automated Multi-Repo IBM App Connect Enterprise BAR Builds
  • Comparing Cloud Hosting vs. Self Hosting
  • Designing a New Framework for Ephemeral Resources
  • gRPC Basics

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: