How to create a proxy to a smart contract - adridadou/eth-contract-api GitHub Wiki

To see an example of how to map a smart contract, you can have a look at https://github.com/adridadou/eth-contract-api/blob/develop/src/test/java/org/adridadou/TestnetConnectionTest.java

EthereumFacadeProvider

This interface represents the provider to your access to an Ethereum network. It has two functions:

  • EthereumFacade create(final ECKey key)
  • ECKey getKey(final String id, final String password)

The idea is to make it easier to get your key and create your ethereum network connection. For example, for Morden and Main net, the function getKey will take your keystore file name as id and the password. But for Ether.camp testnet, you only have to give an id for the private key, no password is needed (it will be ignored)

Then we can do basically two things with your new facade:

  • publish a new smart contract by calling publishContract and the source as a parameter
  • map an existing smart contract by calling createContractProxy(String contractSource, EthAddress address, Class<> smartContractInterface)

For now, the rule is the following, if a method returns nothing (void), then it is seen as a call that needs a transaction. If it has a return type, then it will do a callConstantFunction that does not create any transaction

Type mapping