Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (63 sloc) 3.12 KB

KumuluzEE Ethereum

Build Status

KumuluzEE Ethereum project for seamless development of Blockchain applications, smart contracts, distributed ledger and integration with Ethereum platform. Pre-release version enables you to easily interact with Ethereum network using web3j. Web3j documentation can be found here.

Usage

You can enable KumuluzEE Ethereum support by adding the following dependency to pom.xml:

<dependency>
    <groupId>com.kumuluz.ee.ethereum</groupId>
    <artifactId>kumuluzee-ethereum-web3j</artifactId>
    <version>${kumuluzee-ethereum.version}</version>
</dependency>

Connecting to network

In order to connect to the ethereum network you need to use a client. You can choose to run one yourself such as geth or use client in the cloud such as infura. For testing purposes we recommend you connect to testnet (rovan, kovan or rinekby). In this guide we will use rinkeby. To get free test ether use rinkeby faucet

Creating a wallet

In order to make transactions you need to have a wallet. You can use your existing wallet or get a new one. You can also create a wallet using ethereum client.

Most popular options include:

If you want to perform operations using your account you will need to provide wallet data in config.yaml.

Configuration

To configure web3j instance create configuration in resources/config.yaml. Here you can put path to your wallet and address of the client used to connect to the ethereum network.

kumuluzee:
  ethereum:
    wallet:
      path: "/path/to/wallet.json"
      password: "kumuluzee"
    client:
      address: "http://localhost:8545"

Contracts

If you wish do deploy or interact with Solidity smart contracts you should place them in resources folder.

Usage

You can obtain web3j instance by using Web3jUtils.

private Web3jUtils web3jUtils = Web3jUtils.getInstance();

You can also inject web3j instance using CDI.

    @Inject
    @Web3jUtil
    private Web3j web3j;

Listening to events

In order to listen for events on smart contracts you can use EventListen annotation. This functionality requires you to connect to your own Ethereum client. Cloud clients like Infura are not supported. First create a method and add EventListen annotation. Then add appropriate EventResponse method parameter which will allow you to obtain details about the event.

@EventListen(eventName="transfer", smartContractName = SampleToken.class, smartContractAddress = deployedContractAddress)
    public void reactToEvent (SampleToken.TransferEventResponse transferEventResponse) {
        // transferEventResponse contains event data
   }

License

MIT