https://github.com/web3j/web3j-spring-boot-starter
Spring Boot Starter for web3j
https://github.com/web3j/web3j-spring-boot-starter
blockchain ethereum java spring spring-boot web3j
Last synced: about 2 months ago
JSON representation
Spring Boot Starter for web3j
- Host: GitHub
- URL: https://github.com/web3j/web3j-spring-boot-starter
- Owner: web3j
- Created: 2017-02-19T04:25:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-09T08:13:14.000Z (about 1 year ago)
- Last Synced: 2025-03-29T03:08:15.388Z (about 2 months ago)
- Topics: blockchain, ethereum, java, spring, spring-boot, web3j
- Language: Java
- Size: 193 KB
- Stars: 239
- Watchers: 27
- Forks: 89
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# web3j Spring Boot Starter
[](https://travis-ci.org/web3j/web3j-spring-boot-starter)
Integrate web3j into your Spring Boot applications via Spring's dependency injection.
## Getting started
A sample application is available [here](https://github.com/web3j/examples/tree/master/spring-boot)
To use, create a new [Spring Boot Application](https://spring.io/guides/gs/spring-boot/), and
include the following dependencies:Maven:
```xml
org.web3j
web3j-spring-boot-starter
4.0.3```
Gradle:
```groovy
compile ('org.web3j:web3j-spring-boot-starter:4.0.3')
```Now Spring can inject web3j instances for you where ever you need them:
```java
@Autowired
private Web3j web3j;
```No additional configuration is required if you want to connect via HTTP to the default URL
http://localhost:8545.Otherwise simply add the address of the endpoint in your application properties:
```properties
# An infura endpoint
web3j.client-address = https://rinkeby.infura.io/# Or, an IPC endpoing
web3j.client-address = /path/to/file.ipc
```## Admin clients
If you wish to make use of the personal module methods that are common to both
[Parity](https://github.com/ethcore/parity/wiki/JSONRPC-personal-module) and
[Geth](https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal)
to manage accounts, enable the admin client:```properties
web3j.admin-client = true
```Then Spring can inject admin clients:
```java
@Autowired
private Admin admin;
```## HTTP client configuration
Some Ethereum operations take longer than the default HTTP timeout set by the `OkHttp3` library
used by `web3j`. To configure those timeouts set the web3j `httpTimeoutSeconds` property:```properties
web3j.httpTimeoutSeconds = 600
```This sets all three OkHttp3 timeouts: `connect`, `read`, and `write`.
Valid values are any non-negative integer.
A value of '`0`' means: no timeout.
**Note**: This is not required for transacting with web3j.
## Further information
For further information on web3j, please refer to the [web3j home page](https://web3j.io).