Skip to content

ENS and Truffle (v3.1.0)

Compare
Choose a tag to compare
@conor10 conor10 released this 13 Nov 12:21

ENS support

web3j now supports Ethereum Name Service (ENS) lookups for contract and wallet addresses.

This means that anywhere you previously had to use a contract or wallet address, you can now use an ENS domain name instead.

I.e. For your smart contracts you can use:

YourSmartContract contract = YourSmartContract.load(
        "0x<address>|<ensName>", 
        web3j, credentials, GAS_PRICE, GAS_LIMIT);

It also is supported in web3j’s command line tools:

$ web3j wallet send <walletfile> 0x<address>|<ensName>

Truffle support

The Truffle Framework is a very popular choice for both JavaScript and Solidity developers alike. Truffle provides a contract schema in JSON to represent contracts deployed to the various Ethereum networks.

web3j can now work with Truffle JSON files for generating smart contract wrappers. This means that if you currently or have used Truffle for your smart contract development, you can generate smart contract wrappers in Java from them.

The advantage of this approach is that your smart contracts will know where they’ve been deployed previously.

YourSmartContract contract = YourSmartContract.load(
        YourSmartContract.getDeployedAddress(<network id>), 
        web3j, credentials, GAS_PRICE, GAS_LIMIT);

Where the network id is as per EIP 155.

To generate the wrapper files, there is a new truffle argument to the web3j command line tool:

$ web3j truffle generate [--javaTypes|--solidityTypes] /path/to/<truffle-smart-contract-output>.json -o /path/to/src/main/java -p com.your.organisation.name

@eepstein deserves the credit for this change, as he had the idea and implemented it.

Other items

  • Increment id field on requests (#232) by @IgorPerikov
  • Fixed compiler warnings (#224) by @joanesespanol
  • Event objects containing String and array members are now represented using byte[] values
  • Module dependencies on Bintray not being pulled down (#219)