Skip to content

Commit 59def7c

Browse files
committed
1. Incorporated nonce into transactions being signed via Geth/Parity 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.
1 parent c7ff61c commit 59def7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1343
-191
lines changed

Diff for: README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# web3j: Web3 Java Ðapp API
1+
# web3j: Web3 Java Ethereum Ðapp API
22

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

3838
### Gradle
3939

4040
```groovy
41-
compile ('org.web3j:core:0.5.5')
41+
compile ('org.web3j:core:0.6.0')
4242
```
4343

4444
Start up an Ethereum client if you don't already have one running, such as [Geth](https://github.com/ethereum/go-ethereum/wiki/geth):

Diff for: build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ apply plugin: 'idea'
2323
apply plugin: 'io.codearte.nexus-staging'
2424

2525
group 'org.web3j'
26-
version '0.5.5'
26+
version '0.6.0'
2727

2828
sourceCompatibility = 1.8
2929

Diff for: docs/source/filters.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Working with Filters
2-
====================
1+
Filters
2+
=======
33

4-
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.
4+
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.

Diff for: docs/source/getting_started.rst

+12-5
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ Maven
77
-----
88

99
.. code-block:: xml
10+
1011
<dependency>
1112
<groupId>org.web3j</groupId>
1213
<artifactId>core</artifactId>
13-
<version>0.5.5</version>
14+
<version>0.6.0</version>
1415
</dependency>
1516
1617
Gradle
1718
------
1819

1920
.. code-block:: groovy
20-
compile ('org.web3j:core:0.5.5')
21+
22+
compile ('org.web3j:core:0.6.0')
2123
2224
2325
Start a client
@@ -67,6 +69,11 @@ To use client admin commands::
6769

6870
Further details
6971
---------------
70-
- 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.
71-
- Async requests are handled using Java 8's `CompletableFutures <https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html>`_.
72-
- 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().
72+
- web3j provides type safe access to all responses. Optional or null responses are wrapped in
73+
Java 8's
74+
`Optional <https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html>`_ type.
75+
- Async requests are handled using Java 8's
76+
`CompletableFutures <https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html>`_.
77+
- Quantity payload types are returned as `BigIntegers <https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html>`_.
78+
For simple results, you can obtain the quantity as a String via
79+
`Response <https://github.com/web3j/web3j/blob/master/src/main/java/org/web3j/protocol/core/Response.java>`_.getResult().

Diff for: docs/source/images/pending_transaction.png

194 KB
Loading

Diff for: docs/source/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ Contents:
4242

4343
introduction.rst
4444
getting_started.rst
45-
contract_creation.rst
4645
transactions.rst
46+
smart_contracts.rst
4747
filters.rst
4848
callbacks.rst
49-
solidity_wrappers.rst
5049
rlp.rst
5150
abi.rst
5251
management_apis.rst
5352
infura.rst
53+
trouble.rst
5454
development.rst
5555
links.rst
5656
credits.rst

Diff for: docs/source/infura.rst

+14-6
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,23 @@ Test Ethereum Network (Morden):
1818
Certificate installation
1919
------------------------
2020

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

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

2527
.. image:: /images/infura_cert.png
2628

27-
Alternatively, you can use SSL (this will only download the first certificate in the chain, which should be adequate).
29+
Alternatively, you can use SSL (this will only download the first certificate in the chain, which
30+
should be adequate).
2831

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

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

5864

5965
Transactions
6066
------------
6167

62-
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.
68+
In order to transact with Infura nodes, you will need to create and sign transactions offline
69+
before sending them, as Infura nodes have no visibility of your encrypted Ethereum key files, which
70+
are required to unlock accounts via the Personal Geth/Parity admin commands.
6371

6472
Refer to the :doc:`signing_transactions` and :doc:`management_apis` sections for further details.

Diff for: docs/source/links.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ Links and Useful Resources
44
- Ethereum `Homestead Documentation <https://ethereum-homestead.readthedocs.io/en/latest/>`_
55
- Ethereum `Wiki <https://github.com/ethereum/wiki/wiki>`_
66
- Ethereum `JSON-RPC specification <https://github.com/ethereum/wiki/wiki/JSON-RPC>`_
7-
- Ethereum `Yellow Paper <gavwood.com/paper.pdf>`_ and `GitHub <https://github.com/ethereum/yellowpaper>`_ repository
7+
- Ethereum `Yellow Paper <gavwood.com/paper.pdf>`_ and
8+
`GitHub <https://github.com/ethereum/yellowpaper>`_ repository
89
- `Homestead <https://ethereum-homestead.readthedocs.org/en/latest/>`_ docs
910
- `Solidity <http://solidity.readthedocs.io/en/develop/>`_ docs
1011
- `Ethereum tests <https://github.com/ethereum/tests>`_ contains lots of common tests for clients
11-
- `Etherscan <https://etherscan.io>`_ is very useful for exploring blocks and transactions, it also has a `testnet site <https://testnet.etherscan.io>`_
12-
- `Ethstats <https://ethstats.net/>`_ provides a useful network dashboard
12+
- `Etherscan <https://etherscan.io>`_ is very useful for exploring blocks and transactions, it also
13+
has a `testnet site <https://testnet.etherscan.io>`_
14+
- `Ethstats <https://ethstats.net/>`_ provides a useful network dashboard. There is also a
15+
`testnet dashboard <http://morden.io/>`_, and one for `Parity clients <https://stats.parity.io/>`_.
1316
- `Ethereum reddit <https://www.reddit.com/r/ethereum/>`_

Diff for: docs/source/management_apis.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ As Parity provides a superset of the personal admin commands offered by Geth, yo
1818
// send a transaction, or use parity.personalSignAndSendTransaction() to do it all in one
1919
}
2020

21-
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.
21+
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.

Diff for: docs/source/smart_contracts.rst

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
Smart Contracts
2+
===============
3+
4+
Developers have the choice of three languages for writing smart contracts:
5+
6+
`Solidity <https://solidity.readthedocs.io/>`_
7+
The flagship language of Ethereum, and most popular language for smart contracts.
8+
9+
`Serpent <https://github.com/ethereum/wiki/wiki/Serpent>`_
10+
A Python like language for writing smart contracts.
11+
12+
LISP Like Language (LLL)
13+
A low level language, Serpent provides a superset of LLL. There's not a great deal of information
14+
for working with LLL, the following blog `/var/log/syrinx <http://blog.syrinx.net/>`_ and
15+
associated `Github <https://github.com/zigguratt/lll-resurrected>`_ is a good place to start.
16+
17+
18+
In order to deploy a smart contract onto the Ethereum blockchain, it must first be compiled into
19+
a bytecode format, then it can be sent as part of a transaction request as detailed in
20+
:ref:`creation-of-smart-contract`.
21+
22+
Given that Solidity is the language of choice for writing smart contracts, it is the language
23+
supported by web3j, and is used for all subsequent examples.
24+
25+
26+
Getting started with Solidity
27+
-----------------------------
28+
29+
An overview of Solidity is beyond the scope of these docs, however, the following resources are a
30+
good place to start:
31+
32+
- `Contract Tutorial <https://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial>`_ on the Go
33+
Ethereum Wiki
34+
- `Introduction to Smart Contracts <http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html>`_
35+
in the Solidity project documentation
36+
- `Writing a contract <https://ethereum-homestead.readthedocs.io/en/latest/contracts-and-transactions/contracts.html#writing-a-contract>`_
37+
in the Ethereum Homestead Guide
38+
39+
40+
Compiling Solidity source code
41+
------------------------------
42+
43+
Compilation to bytecode is performed by the Solidity compiler, *solc*. You can install the compiler,
44+
locally following the instructions as per
45+
`the project documentation <https://solidity.readthedocs.io/en/latest/installing-solidity.html>`_.
46+
47+
To compile the solidity code run:
48+
49+
.. code-block:: bash
50+
51+
$ solc <contract>.sol --bin --abi --optimize -o <output-dir>/
52+
53+
**Note**: there are issues with installing solc via homebrew on OS X currently, please see the
54+
following `thread <https://github.com/ethereum/cpp-ethereum/issues/3173#issuecomment-255991056>`_
55+
for further information.
56+
57+
The *--bin* and *--abi* compiler arguments are both required to take full advantage of working
58+
with smart contracts from web3j.
59+
60+
*--bin*
61+
Outputs a Solidity binary file containing the hex-encoded binary to provide with the transaction
62+
request (as per :ref:`creation-of-smart-contract`).
63+
64+
*--abi*
65+
Outputs a solidity application binary interface (ABI) file which details all of the publicly
66+
acessible contract methods and their associated parameters. These details along with the
67+
contract address are crucial for interacting with smart contracts. The ABI file is also used for
68+
the generation of :ref:`smart-contract-wrappers`.
69+
70+
There is also a *--gas* argument for providing estimates of the :ref:`gas` required to create a
71+
contract and transact with its methods.
72+
73+
74+
Alternatively, you can write and compile solidity code in your browser via the
75+
`Browser-Solidity <https://ethereum.github.io/browser-solidity/>`_. Browser-Solidity is great for
76+
smaller smart contracts, but you may run into issues working with larger contracts.
77+
78+
You can also compile solidity code via Ethereum clients such as Geth and Parity, using the JSON-RPC
79+
method `eth_compileSolidity <https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilesolidity>`_
80+
which is also supported in web3j. However, the Solidity compiler must be installed on the client
81+
for this to work.
82+
83+
There are further options available, please refer to the
84+
`relevant section <https://ethereum-homestead.readthedocs.io/en/latest/contracts-and-transactions/contracts.html#compiling-a-contract>`_
85+
in the Homestead documentation.
86+
87+
88+
Deploying and interacting with smart contracts
89+
-------------------------------------
90+
91+
Please refer to the sections :ref:`creation-of-smart-contract`, :ref:`transacting-with-contract`
92+
and :ref:`querying-state` for details.
93+
94+
95+
Smart contract examples
96+
-----------------------
97+
98+
web3j provides a number of smart contract examples in the project directory
99+
`src/test/resources/solidity <https://github.com/web3j/web3j/tree/master/src/test/resources/solidity>`_
100+
101+
It also provides integration tests for demonstrating the deploying and working with those smart
102+
contracts in the project directory
103+
`src/integration-test/java/org/web3j/protocol/scenarios <https://github.com/web3j/web3j/tree/master/src/integration-test/java/org/web3j/protocol/scenarios>`_.
104+
105+
106+
EIP-20 Ethereum token standard smart contract
107+
---------------------------------------------
108+
109+
There is an active `Ethereum Improvement Proposal (EIP) <https://github.com/ethereum/EIPs>`_,
110+
`EIP-20 <https://github.com/ethereum/EIPs/issues/20>`_ that has been created to define the standard
111+
functions that a smart contract providing tokens can implement.
112+
113+
The EIP-20 proposal provides function definitions, but does not provide an implementation example.
114+
However, there is an implementation provided in
115+
`src/test/resources/solidity/contracts <https://github.com/web3j/web3j/tree/master/src/test/resources/solidity/contracts>`_,
116+
which has been taken from Consensys' implementation on
117+
`GitHub <https://github.com/ConsenSys/Tokens>`_.
118+
119+
The integration test
120+
`HumanStandardTokenIT <https://github.com/web3j/web3j/tree/master/src/integration-test/java/org/web3j/protocol/scenarios/HumanStandardTokenIT.java>`_.
121+
has been been written to fully demonstrate the functionality of this token standard smart contract.
122+
123+
124+
.. _smart-contract-wrappers:
125+
126+
Solidity smart contract wrappers
127+
--------------------------------
128+
129+
web3j supports the auto-generation of smart contract function wrappers in Java from Solidity ABI files.
130+
131+
This can be achieved by running:
132+
133+
.. code-block:: bash
134+
135+
org.web3j.codegen.SolidityFunctionWrapperGenerator /path/to/<smart-contract>.abi -o /path/to/src/dir/java -p com.your.organisation.name
136+
137+
See `FunctionWrappersIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/scenarios/FunctionWrappersIT.java>`_
138+
for an example of using a generated smart contract Java wrapper.
139+
140+
**Note:** at present the wrappers invoke smart contracts via
141+
`EthCall <https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call>`_,
142+
so a transaction does not take place. Transaction support is imminent.
143+
144+
For an example of how to call a smart contracts via a transaction, refer to
145+
`DeployContractIT <https://github.com/web3j/web3j/blob/master/src/integration-test/java/org/web3j/protocol/scenarios/DeployContractIT.java>`_.

Diff for: docs/source/solidity_wrappers.rst

-16
This file was deleted.

0 commit comments

Comments
 (0)