I am a Java developer. I want to write a smart contract using Java and deploy it to a private blockchain network.
Does Ethereum provide the facility to write smart contracts using Java language? If yes, how can I do this?
I am a Java developer. I want to write a smart contract using Java and deploy it to a private blockchain network.
Does Ethereum provide the facility to write smart contracts using Java language? If yes, how can I do this?
To start you can use web3j. It is Java library that allow the iteration of java application with contracts in the Ethereum network.
It doesn't provide the capability to write contracts in java, but you can interact with contracts written in Solidity.
It generates Smart Contract wrappers in Java from a Solidity compiled binary and ABI file.
Once you've generated the wrapper code with web3j, you will be able to deploy, then call the methods on the above contract example as follows:
Ex:
SimpleStorage simpleStorage = SimpleStorage.deploy(
<web3j>, <credentials>, GAS_PRICE, GAS_LIMIT,
BigInteger.ZERO); // ether value of contract
TransactionReceipt transactionReceipt = simpleStorage.set(
new Uint256(BigInteger.valueOf(1000))),
.get();
Uint256 result = simpleStorage.get()
.get();
Currently, Smart Contracts can be written in three languages:
Solidity - Similar to JavaScript
Serpent - Python derivative
LLL(Lisp Like Language) - Similar to Assembly
You can find more information about these languages here.
Solidity is designed especially for writing smart contracts and is the flagship language of Ethereum. You can start reading about it here.
The ICON blockchain will support java smart contracts in ICON 2.0 due to be released August 2021 and currently running on a testnet.
You can also checkout code examples -> https://github.com/icon-project/java-score-examples.
It's not out yet but you might be interested in Corda, which is being developed by Mike Hearn and his team on behalf of the R3 consortium. This targets Java developers, and doesn't use a blockchain, as is appropriate for a lot of private blockchain projects in the financial sector.
Per this discussion some code will be released soon: https://m.youtube.com/watch?v=3YTSwB5UrEI
You can not write contracts in Java, but deploying should work with the Ethereum Contract API native in Java. The goal is to ease the integration of Ethereum in a Java project.
- Easy configuration of the network and keypair use
- Create an interface for a smart contract
- Have type safety in regards of input and output values
- Easy transaction creation
- Easy synchronization when creating a transaction
- Transaction creation returns Future, simple calls returns the value itself
On youtube is a short presentation (15 minutes) from the Berlin Ethereum meetup.
Yes.
Jthereum supports writing contracts for the Ethereum blockchain in Java.
It is a commercial product targeted at enterprise use.
The product is currently in beta testing, but is available for download and use at no charge at this time (4/19/2021)
<http://jthereum.com> so it is clickable:
http://jthereum.com
– Paul Verest
Apr 20 '21 at 15:07