LFDT-web3j/web3j-unit
LFDT-web3j/web3j-unit has 30 GitHub stars and 21 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-16 04:25 UTC. Last push 2026-11-13.
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
Smart contract testing framework via integrated EVM and various Ethereum clients
Developer ToolsREADME.md
OriginalWeb3j-unit 
Web3j-unit is a Junit 5 extension to streamline the creation of Ethereum contract tests.
Multiple Ethereum implementations are supported including Geth and Besu. To run tests built using Web3j-unit, docker is required on the host.
Instances of Web3j, TransactionManager and GasProvider are injected into the Junit runner.
You can find a sample here.
You can find an example using docker-compose here. This spins up VMWare Concord nodes using a docker-compose file.
Getting Started
- Add dependency to gradle.
repositories {
mavenCentral()
maven { url "https://hyperledger.jfrog.io/artifactory/besu-maven/" }
maven { url "https://artifacts.consensys.net/public/maven/maven/" }
maven { url "https://splunk.jfrog.io/splunk/ext-releases-local" }
maven { url "https://dl.cloudsmith.io/public/consensys/quorum-mainnet-launcher/maven/" }
}
implementation "org.web3j:core:6.1.0"
testCompile "org.web3j:web3j-unit:6.1.0"
- Create a new test with the
@EVMTestannotation. An embedded EVM is used by default. To use Geth or Besu pass the node type into the annotation:@EVMTest(NodeType.GETH)or@EVMTest(NodeType.BESU)
@EVMTest
class GreeterTest {
}
- Inject instance of
Web3jTransactionManagerandContractGasProviderin your test method.
@EVMTest
class GreeterTest {
@Test
fun greeterDeploys(
web3j: Web3j,
transactionManager: TransactionManager,
gasProvider: ContractGasProvider
) {}
}
- Deploy your contract in the test.
@EVMTest
class GreeterTest {
@Test
fun greeterDeploys(
web3j: Web3j,
transactionManager: TransactionManager,
gasProvider: ContractGasProvider
) {
val greeter = Greeter.deploy(web3j, transactionManager, gasProvider, "Hello EVM").send()
val greeting = greeter.greet().send()
assertEquals("Hello EVM", greeting)
}
}
- Run the test!
Using a custom docker-compose file
- Add dependency to gradle.
repositories {
mavenCentral()
}
implementation "org.web3j:core:5.0.1"
testCompile "org.web3j:web3j-unit:5.0.1"
- Create a new test with the
@EVMComposeTestannotation. By default, usestest.ymlfile in the project home, and runsweb3jon service namenode1exposing the port8545. Can be customised to use specific docker-compose file, service name and port by@EVMComposeTest("src/test/resources/geth.yml", "ethnode1", 8080)Here, we connect to the service namedethnode1in thesrc/test/resources/geth.ymldocker-compose file which exposes the port8080forweb3jto connect to.
@EVMComposeTest("src/test/resources/geth.yml", "ethnode1", 8080)
class GreeterTest {
}
- Inject instance of
Web3jTransactionManagerandContractGasProviderin your test method.
@EVMComposeTest("src/test/resources/geth.yml", "ethnode1", 8080)
class GreeterTest {
@Test
fun greeterDeploys(
web3j: Web3j,
transactionManager: TransactionManager,
gasProvider: ContractGasProvider
) {}
}
- Deploy your contract in the test.
@EVMComposeTest("src/test/resources/geth.yml", "ethnode1", 8080)
class GreeterTest {
@Test
fun greeterDeploys(
web3j: Web3j,
transactionManager: TransactionManager,
gasProvider: ContractGasProvider
) {
val greeter = Greeter.deploy(web3j, transactionManager, gasProvider, "Hello EVM").send()
val greeting = greeter.greet().send()
assertEquals("Hello EVM", greeting)
}
}
- Run the test!