Skip to content

Commit

Permalink
1. Incorporated nonce into transactions being signed via Geth/Parity …
Browse files Browse the repository at this point in the history
…nodes

2. Created EIP-20 standard token integration test
3. Created Greeter integration test
4. Addressed bug where function encoder wouldn't process "0x" properly if return arguments were expected
5. Created Credentials container for account credentials
6. Added additional smart contract source code
7. Created Smart Contract documentation section
8. Created troubleshooting documentation section
9. Updates to transaction documentation
10. Cleaned up layout of source files for other documentation files.
11. Bumped version.
  • Loading branch information
conor10 committed Oct 28, 2016
1 parent c7ff61c commit 59def7c
Show file tree
Hide file tree
Showing 44 changed files with 1,343 additions and 191 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# web3j: Web3 Java Ðapp API
# web3j: Web3 Java Ethereum Ðapp API

[![Documentation Status](https://readthedocs.org/projects/web3j/badge/?version=latest)](http://web3j.readthedocs.io/en/latest/?badge=latest)
[![Build Status](https://travis-ci.org/web3j/web3j.svg?branch=master)](https://travis-ci.org/web3j/web3j)
Expand Down Expand Up @@ -31,14 +31,14 @@ Add the following dependency to your project:
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>0.5.5</version>
<version>0.6.0</version>
</dependency>
```

### Gradle

```groovy
compile ('org.web3j:core:0.5.5')
compile ('org.web3j:core:0.6.0')
```

Start up an Ethereum client if you don't already have one running, such as [Geth](https://github.com/ethereum/go-ethereum/wiki/geth):
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ apply plugin: 'idea'
apply plugin: 'io.codearte.nexus-staging'

group 'org.web3j'
version '0.5.5'
version '0.6.0'

sourceCompatibility = 1.8

Expand Down
6 changes: 3 additions & 3 deletions docs/source/filters.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Working with Filters
====================
Filters
=======

Please refer to `org.web3j.protocol.scenarios.EventFilterIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/scenarios/EventFilterIT.java>`_ for an example of how to do this until this section is written.
Please refer to `EventFilterIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/scenarios/EventFilterIT.java>`_ for an example of how to do this until this section is written.
17 changes: 12 additions & 5 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ Maven
-----

.. code-block:: xml
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>0.5.5</version>
<version>0.6.0</version>
</dependency>
Gradle
------

.. code-block:: groovy
compile ('org.web3j:core:0.5.5')
compile ('org.web3j:core:0.6.0')
Start a client
Expand Down Expand Up @@ -67,6 +69,11 @@ To use client admin commands::

Further details
---------------
- web3j provides type safe access to all responses. Optional or null responses are wrapped in Java 8's `Optional <https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html>`_ type.
- Async requests are handled using Java 8's `CompletableFutures <https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html>`_.
- Quantity payload types are returned as `BigIntegers <https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html>`_. For simple results, you can obtain the quantity as a String via `org.web3j.protocol.core.Response <https://github.com/web3j/web3j/blob/master/src/main/java/org/web3j/protocol/core/Response.java>`_.getResult().
- web3j provides type safe access to all responses. Optional or null responses are wrapped in
Java 8's
`Optional <https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html>`_ type.
- Async requests are handled using Java 8's
`CompletableFutures <https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html>`_.
- Quantity payload types are returned as `BigIntegers <https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html>`_.
For simple results, you can obtain the quantity as a String via
`Response <https://github.com/web3j/web3j/blob/master/src/main/java/org/web3j/protocol/core/Response.java>`_.getResult().
Binary file added docs/source/images/pending_transaction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Contents:

introduction.rst
getting_started.rst
contract_creation.rst
transactions.rst
smart_contracts.rst
filters.rst
callbacks.rst
solidity_wrappers.rst
rlp.rst
abi.rst
management_apis.rst
infura.rst
trouble.rst
development.rst
links.rst
credits.rst
20 changes: 14 additions & 6 deletions docs/source/infura.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ Test Ethereum Network (Morden):
Certificate installation
------------------------

As the Infura nodes are accessed over TLS, you will need to install the relevant certificates into your Java Virtual Machine's keystore.
As the Infura nodes are accessed over TLS, you will need to install the relevant certificates into
your Java Virtual Machine's keystore.

You can obtain the certificate using the `Firefox <https://www.mozilla.org/en-US/firefox/new/>`_ web browser:
You can obtain the certificate using the `Firefox <https://www.mozilla.org/en-US/firefox/new/>`_
web browser:

.. image:: /images/infura_cert.png

Alternatively, you can use SSL (this will only download the first certificate in the chain, which should be adequate).
Alternatively, you can use SSL (this will only download the first certificate in the chain, which
should be adequate).

.. code-block:: bash
$ openssl s_client -connect morden.infura.io:443 -showcerts </dev/null 2>/dev/null|openssl x509 -outform PEM > infura-morden.pem
Once you have downloaded it, then install it into your keystore (for Windows/Linux hosts the paths will differ slightly):
Once you have downloaded it, then install it into your keystore (for Windows/Linux hosts the paths
will differ slightly):

.. code-block:: bash
Expand All @@ -53,12 +57,16 @@ You can now use Infura to work with the Ethereum blockchain.
Parity//v1.3.5-beta/x86_64-linux-gnu/rustc1.12.0
If you want to test a number of the JSON-RPC calls against Infura, update the integration test `org.web3j.protocol.core.CoreIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/core/CoreIT.java>`_ with your Infura URL & run it.
If you want to test a number of the JSON-RPC calls against Infura, update the integration test
`CoreIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/core/CoreIT.java>`_
with your Infura URL & run it.


Transactions
------------

In order to transact with Infura nodes, you will need to create and sign transactions offline before sending them, as Infura nodes have no visibility of your encrypted Ethereum key files, which are required to unlock accounts via the Personal Geth/Parity admin commands.
In order to transact with Infura nodes, you will need to create and sign transactions offline
before sending them, as Infura nodes have no visibility of your encrypted Ethereum key files, which
are required to unlock accounts via the Personal Geth/Parity admin commands.

Refer to the :doc:`signing_transactions` and :doc:`management_apis` sections for further details.
9 changes: 6 additions & 3 deletions docs/source/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ Links and Useful Resources
- Ethereum `Homestead Documentation <https://ethereum-homestead.readthedocs.io/en/latest/>`_
- Ethereum `Wiki <https://github.com/ethereum/wiki/wiki>`_
- Ethereum `JSON-RPC specification <https://github.com/ethereum/wiki/wiki/JSON-RPC>`_
- Ethereum `Yellow Paper <gavwood.com/paper.pdf>`_ and `GitHub <https://github.com/ethereum/yellowpaper>`_ repository
- Ethereum `Yellow Paper <gavwood.com/paper.pdf>`_ and
`GitHub <https://github.com/ethereum/yellowpaper>`_ repository
- `Homestead <https://ethereum-homestead.readthedocs.org/en/latest/>`_ docs
- `Solidity <http://solidity.readthedocs.io/en/develop/>`_ docs
- `Ethereum tests <https://github.com/ethereum/tests>`_ contains lots of common tests for clients
- `Etherscan <https://etherscan.io>`_ is very useful for exploring blocks and transactions, it also has a `testnet site <https://testnet.etherscan.io>`_
- `Ethstats <https://ethstats.net/>`_ provides a useful network dashboard
- `Etherscan <https://etherscan.io>`_ is very useful for exploring blocks and transactions, it also
has a `testnet site <https://testnet.etherscan.io>`_
- `Ethstats <https://ethstats.net/>`_ provides a useful network dashboard. There is also a
`testnet dashboard <http://morden.io/>`_, and one for `Parity clients <https://stats.parity.io/>`_.
- `Ethereum reddit <https://www.reddit.com/r/ethereum/>`_
2 changes: 1 addition & 1 deletion docs/source/management_apis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ As Parity provides a superset of the personal admin commands offered by Geth, yo
// send a transaction, or use parity.personalSignAndSendTransaction() to do it all in one
}

Refer to the integration test `org.web3j.protocol.parity.ParityIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/parity/ParityIT.java>`_ for further implementation details.
Refer to the integration test `ParityIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/parity/ParityIT.java>`_ for further implementation details.
145 changes: 145 additions & 0 deletions docs/source/smart_contracts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
Smart Contracts
===============

Developers have the choice of three languages for writing smart contracts:

`Solidity <https://solidity.readthedocs.io/>`_
The flagship language of Ethereum, and most popular language for smart contracts.

`Serpent <https://github.com/ethereum/wiki/wiki/Serpent>`_
A Python like language for writing smart contracts.

LISP Like Language (LLL)
A low level language, Serpent provides a superset of LLL. There's not a great deal of information
for working with LLL, the following blog `/var/log/syrinx <http://blog.syrinx.net/>`_ and
associated `Github <https://github.com/zigguratt/lll-resurrected>`_ is a good place to start.


In order to deploy a smart contract onto the Ethereum blockchain, it must first be compiled into
a bytecode format, then it can be sent as part of a transaction request as detailed in
:ref:`creation-of-smart-contract`.

Given that Solidity is the language of choice for writing smart contracts, it is the language
supported by web3j, and is used for all subsequent examples.


Getting started with Solidity
-----------------------------

An overview of Solidity is beyond the scope of these docs, however, the following resources are a
good place to start:

- `Contract Tutorial <https://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial>`_ on the Go
Ethereum Wiki
- `Introduction to Smart Contracts <http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html>`_
in the Solidity project documentation
- `Writing a contract <https://ethereum-homestead.readthedocs.io/en/latest/contracts-and-transactions/contracts.html#writing-a-contract>`_
in the Ethereum Homestead Guide


Compiling Solidity source code
------------------------------

Compilation to bytecode is performed by the Solidity compiler, *solc*. You can install the compiler,
locally following the instructions as per
`the project documentation <https://solidity.readthedocs.io/en/latest/installing-solidity.html>`_.

To compile the solidity code run:

.. code-block:: bash
$ solc <contract>.sol --bin --abi --optimize -o <output-dir>/
**Note**: there are issues with installing solc via homebrew on OS X currently, please see the
following `thread <https://github.com/ethereum/cpp-ethereum/issues/3173#issuecomment-255991056>`_
for further information.

The *--bin* and *--abi* compiler arguments are both required to take full advantage of working
with smart contracts from web3j.

*--bin*
Outputs a Solidity binary file containing the hex-encoded binary to provide with the transaction
request (as per :ref:`creation-of-smart-contract`).

*--abi*
Outputs a solidity application binary interface (ABI) file which details all of the publicly
acessible contract methods and their associated parameters. These details along with the
contract address are crucial for interacting with smart contracts. The ABI file is also used for
the generation of :ref:`smart-contract-wrappers`.

There is also a *--gas* argument for providing estimates of the :ref:`gas` required to create a
contract and transact with its methods.


Alternatively, you can write and compile solidity code in your browser via the
`Browser-Solidity <https://ethereum.github.io/browser-solidity/>`_. Browser-Solidity is great for
smaller smart contracts, but you may run into issues working with larger contracts.

You can also compile solidity code via Ethereum clients such as Geth and Parity, using the JSON-RPC
method `eth_compileSolidity <https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilesolidity>`_
which is also supported in web3j. However, the Solidity compiler must be installed on the client
for this to work.

There are further options available, please refer to the
`relevant section <https://ethereum-homestead.readthedocs.io/en/latest/contracts-and-transactions/contracts.html#compiling-a-contract>`_
in the Homestead documentation.


Deploying and interacting with smart contracts
-------------------------------------

Please refer to the sections :ref:`creation-of-smart-contract`, :ref:`transacting-with-contract`
and :ref:`querying-state` for details.


Smart contract examples
-----------------------

web3j provides a number of smart contract examples in the project directory
`src/test/resources/solidity <https://github.com/web3j/web3j/tree/master/src/test/resources/solidity>`_

It also provides integration tests for demonstrating the deploying and working with those smart
contracts in the project directory
`src/integration-test/java/org/web3j/protocol/scenarios <https://github.com/web3j/web3j/tree/master/src/integration-test/java/org/web3j/protocol/scenarios>`_.


EIP-20 Ethereum token standard smart contract
---------------------------------------------

There is an active `Ethereum Improvement Proposal (EIP) <https://github.com/ethereum/EIPs>`_,
`EIP-20 <https://github.com/ethereum/EIPs/issues/20>`_ that has been created to define the standard
functions that a smart contract providing tokens can implement.

The EIP-20 proposal provides function definitions, but does not provide an implementation example.
However, there is an implementation provided in
`src/test/resources/solidity/contracts <https://github.com/web3j/web3j/tree/master/src/test/resources/solidity/contracts>`_,
which has been taken from Consensys' implementation on
`GitHub <https://github.com/ConsenSys/Tokens>`_.

The integration test
`HumanStandardTokenIT <https://github.com/web3j/web3j/tree/master/src/integration-test/java/org/web3j/protocol/scenarios/HumanStandardTokenIT.java>`_.
has been been written to fully demonstrate the functionality of this token standard smart contract.


.. _smart-contract-wrappers:

Solidity smart contract wrappers
--------------------------------

web3j supports the auto-generation of smart contract function wrappers in Java from Solidity ABI files.

This can be achieved by running:

.. code-block:: bash
org.web3j.codegen.SolidityFunctionWrapperGenerator /path/to/<smart-contract>.abi -o /path/to/src/dir/java -p com.your.organisation.name
See `FunctionWrappersIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/scenarios/FunctionWrappersIT.java>`_
for an example of using a generated smart contract Java wrapper.

**Note:** at present the wrappers invoke smart contracts via
`EthCall <https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call>`_,
so a transaction does not take place. Transaction support is imminent.

For an example of how to call a smart contracts via a transaction, refer to
`DeployContractIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/scenarios/DeployContractIT.java>`_.
16 changes: 0 additions & 16 deletions docs/source/solidity_wrappers.rst

This file was deleted.

Loading

0 comments on commit 59def7c

Please sign in to comment.