Skip to content

Commit 0f7acf6

Browse files
committed
Merge remote-tracking branch 'origin/master' into android
# Conflicts: # src/integration-test/java/org/web3j/generated/Greeter.java # src/integration-test/java/org/web3j/protocol/scenarios/FunctionWrappersIT.java # src/main/java/org/web3j/abi/Contract.java # src/main/java/org/web3j/abi/Transfer.java # src/test/java/org/web3j/utils/StringsTest.java
2 parents 87e598f + f9f26fb commit 0f7acf6

26 files changed

+366
-118
lines changed

README.rst

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ web3j: Web3 Java Ethereum Ðapp API
2424
:target: https://gitter.im/web3j/web3j?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
2525
:alt: Join the chat at https://gitter.im/web3j/web3j
2626

27-
web3j is a lightweight, type safe Java library for integrating with clients (nodes) on the
28-
Ethereum network:
27+
web3j is a lightweight, type safe Java and Android library for integrating with clients (nodes) on
28+
the Ethereum network:
2929

30-
.. image:: https://raw.githubusercontent.com/web3j/web3j/master/docs/source/images/web3j-network.png
30+
.. image:: https://raw.githubusercontent.com/web3j/web3j/master/docs/source/images/web3j_network.png
3131

3232
This allows you to work with the `Ethereum <https://www.ethereum.org/>`_ blockchain, without the
3333
additional overhead of having to write your own integration code for the platform.
@@ -153,13 +153,20 @@ To send synchronous requests:
153153
Web3j web3 = Web3jFactory.build(new HttpService()); // defaults to http://localhost:8545/
154154
...
155155
156-
Sending transactions
157-
--------------------
156+
Transactions
157+
------------
158+
159+
web3j provides support for both working with Ethereum wallet files (recommended) and Ethereum
160+
client admin commands for sending transactions.
161+
162+
To send Ether to another party using your Ethereum wallet file::
158163

159-
web3j provides support for both working with Ethereum wallet files and Ethereum client admin
160-
commands for sending transactions.
164+
Web3j web3 = Web3j.build(new HttpService()); // defaults to http://localhost:8545/
165+
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile");
166+
TransactionReceipt transactionReceipt = Transfer.sendFunds(
167+
web3, credentials, "0x...", BigDecimal.valueOf(1.0), Convert.Unit.ETHER);
161168

162-
Using an Ethereum wallet file::
169+
Or if you wish to create your own custom transaction::
163170

164171
Web3j web3 = Web3j.build(new HttpService()); // defaults to http://localhost:8545/
165172
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile");
@@ -182,7 +189,6 @@ Using an Ethereum wallet file::
182189
Although it's far simpler using web3j's
183190
`Java smart contract wrappers`_.
184191

185-
186192
Using an Ethereum client's admin commands (make sure you have your wallet in the client's
187193
keystore)::
188194

@@ -224,13 +230,15 @@ Now you can create and deploy your smart contract::
224230
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile");
225231

226232
YourSmartContract contract = YourSmartContract.deploy(
227-
<web3j>, <credentials>, <initialEtherValue>,
233+
<web3j>, <credentials>,
234+
GAS_PRICE, GAS_LIMIT,
235+
<initialEtherValue>,
228236
<param1>, ..., <paramN>).get(); // constructor params
229237

230238
Or use an existing::
231239

232240
YourSmartContract contract = YourSmartContract.load(
233-
"0x<address>", <web3j>, <credentials>);
241+
"0x<address>", <web3j>, <credentials>, GAS_PRICE, GAS_LIMIT);
234242

235243
To Transact with a smart contract::
236244

@@ -343,4 +351,4 @@ Thanks and credits
343351
- And of course the users of the library, who've provided valuable input & feedback -
344352
`@ice09 <https://github.com/ice09>`_, `@adridadou <https://github.com/adridadou>`_,
345353
`@nickmelis <https://github.com/nickmelis>`_, `@basavk <https://github.com/basavk>`_,
346-
`@kabl <https://github.com/kabl>`_
354+
`@kabl <https://github.com/kabl>`_, `@MaxBinnewies <https://github.com/MaxBinnewies>`_

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
2626
apply plugin: 'application'
2727

2828
group 'org.web3j'
29-
version '1.0.5'
29+
version '1.0.6'
3030

3131
sourceCompatibility = 1.6
3232
targetCompatibility = 1.6

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ devhelp:
113113
@echo
114114
@echo "Build finished."
115115
@echo "To view the help file:"
116-
@echo "# mkdir -prf $$HOME/.local/share/devhelp/web3j"
116+
@echo "# mkdir -p $$HOME/.local/share/devhelp/web3j"
117117
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/web3j"
118118
@echo "# devhelp"
119119

docs/source/getting_started.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,20 @@ To send synchronous requests::
8686
...
8787
8888
89-
Sending transactions
90-
--------------------
89+
Transactions
90+
------------
9191

92-
web3j provides support for both working with Ethereum wallet files and Ethereum client admin
93-
commands for sending transactions.
92+
web3j provides support for both working with Ethereum wallet files (recommended) and Ethereum
93+
client admin commands for sending transactions.
9494

95-
Using an Ethereum wallet file::
95+
To send Ether to another party using your Ethereum wallet file::
96+
97+
Web3j web3 = Web3j.build(new HttpService()); // defaults to http://localhost:8545/
98+
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile");
99+
TransactionReceipt transactionReceipt = Transfer.sendFunds(
100+
web3, credentials, "0x...", BigDecimal.valueOf(1.0), Convert.Unit.ETHER);
101+
102+
Or if you wish to create your own custom transaction::
96103

97104
Web3j web3 = Web3j.build(new HttpService()); // defaults to http://localhost:8545/
98105
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile");
@@ -106,7 +113,7 @@ Using an Ethereum wallet file::
106113
RawTransaction rawTransaction = RawTransaction.createEtherTransaction(
107114
nonce, <gas price>, <gas limit>, <toAddress>, <value>);
108115

109-
// sign & sendn our transaction
116+
// sign & send our transaction
110117
byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
111118
String hexValue = Hex.toHexString(signedMessage);
112119
EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();
@@ -115,7 +122,6 @@ Using an Ethereum wallet file::
115122
Although it's far simpler using web3j's
116123
:ref:`smart contract wrappers <smart-contract-wrappers-summary>`.
117124

118-
119125
Using an Ethereum client's admin commands (make sure you have your wallet in the client's
120126
keystore)::
121127

@@ -139,7 +145,7 @@ To generate the wrapper code, compile your smart contract:
139145
140146
$ solc <contract>.sol --bin --abi --optimize -o <output-dir>/
141147
142-
Then generate the wrapper code using web3j's :ref:`command_line`:
148+
Then generate the wrapper code using web3j's :doc:`command_line`:
143149

144150
.. code-block:: bash
145151
@@ -151,13 +157,15 @@ Now you can create and deploy your smart contract::
151157
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile");
152158

153159
YourSmartContract contract = YourSmartContract.deploy(
154-
<web3j>, <credentials>, <initialEtherValue>,
160+
<web3j>, <credentials>,
161+
GAS_PRICE, GAS_LIMIT,
162+
<initialEtherValue>,
155163
<param1>, ..., <paramN>).get(); // constructor params
156164

157165
Or use an existing::
158166

159167
YourSmartContract contract = YourSmartContract.load(
160-
"0x<address>", <web3j>, <credentials>);
168+
"0x<address>", <web3j>, <credentials>, GAS_PRICE, GAS_LIMIT);
161169

162170
To transact with a smart contract::
163171

docs/source/index.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
web3j
44
=====
55

6-
web3j is a lightweight, type safe Java library for integrating with clients (nodes) on the
7-
Ethereum network:
6+
web3j is a lightweight, type safe Java and Android library for integrating with clients (nodes) on
7+
the Ethereum network:
88

9-
.. code-block:: bash
10-
11-
[ JVM application ] + [ web3j ] <---> [ Ethereum node ]
9+
.. image:: /images/web3j_network.png
1210

1311
This allows you to work with the `Ethereum <https://www.ethereum.org/>`_ blockchain, without the
1412
additional overhead of having to write your own integration code for the platform.

docs/source/smart_contracts.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ Construction and deployment
182182
Construction and deployment of smart contracts happens with the *deploy* method::
183183

184184
YourSmartContract contract = YourSmartContract.deploy(
185-
<web3j>, <credentials>, <initialValue>,
185+
<web3j>, <credentials>, GAS_PRICE, GAS_LIMIT,
186+
<initialValue>,
186187
<param1>, ..., <paramN>);
187188

188189
This will create a new instance of the smart contract on the Ethereum blockchain using the
@@ -192,7 +193,8 @@ It returns a new smart contract wrapper instance which contains the underlying a
192193
smart contract. If you wish to construct an instance of a smart contract wrapper with an existing
193194
smart contract, simply pass in it's address::
194195

195-
YourSmartContract contract = new YourSmartContract("0x...", web3j, credentials);
196+
YourSmartContract contract = new YourSmartContract(
197+
"0x...", web3j, credentials, GAS_PRICE, GAS_LIMIT);
196198

197199

198200
.. _invoking-transactions:

src/integration-test/java/org/web3j/generated/Arrays.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
public final class Arrays extends Contract {
2424
private static final String BINARY = "60606040526101f5806100126000396000f3606060405260e060020a6000350463b96f54d18114610029578063beda363b146100bc575b610002565b34610002576040805161014081810190925261018191600491610144918390600a90839083908082843750909550505050505061014060405190810160405280600a905b600081526020019060019003908161006d5750600a905060005b818110156101ee5783816001018303600a8110156100025760200201518382600a811015610002576020020152600101610087565b3461000257604080516020600480358082013583810280860185019096528085526101a49592946024949093928501928291850190849080828437509496505050505050506040805160208101825260008082528351925191929182908059106101235750595b90808252806020026020018201604052801561013a575b509250600090505b818110156101ee578381600101830381518110156100025790602001906020020151838281518110156100025760209081029091010152600101610142565b60405180826101408083818460006004602df15090500191505060405180910390f35b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b505091905056";
2525

26-
private Arrays(String contractAddress, Web3j web3j, Credentials credentials) {
27-
super(contractAddress, web3j, credentials);
26+
private Arrays(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
27+
super(contractAddress, web3j, credentials, gasPrice, gasLimit);
2828
}
2929

3030
public Future<TransactionReceipt> fixedReverse(StaticArray<Uint256> input) {
@@ -37,11 +37,11 @@ public Future<TransactionReceipt> dynamicReverse(DynamicArray<Uint256> input) {
3737
return executeTransactionAsync(function);
3838
}
3939

40-
public static Future<Arrays> deploy(Web3j web3j, Credentials credentials, BigInteger initialValue) {
41-
return deployAsync(Arrays.class, web3j, credentials, BINARY, "", initialValue);
40+
public static Future<Arrays> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue) {
41+
return deployAsync(Arrays.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialValue);
4242
}
4343

44-
public static Arrays load(String contractAddress, Web3j web3j, Credentials credentials) {
45-
return new Arrays(contractAddress, web3j, credentials);
44+
public static Arrays load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
45+
return new Arrays(contractAddress, web3j, credentials, gasPrice, gasLimit);
4646
}
4747
}

src/integration-test/java/org/web3j/generated/Fibonacci.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
public final class Fibonacci extends Contract {
2525
private static final String BINARY = "606060405260d18060106000396000f3606060405260e060020a60003504633c7fdc708114602657806361047ff4146044575b6002565b34600257605160043560006063825b600081151560a75750600060a2565b3460025760516004356035565b60408051918252519081900360200190f35b604080518481526020810183905281519293507f71e71a8458267085d5ab16980fd5f114d2d37f232479c245d523ce8d23ca40ed929081900390910190a15b919050565b816001141560b65750600160a2565b60c0600283036035565b60ca600184036035565b01905060a256";
2626

27-
private Fibonacci(String contractAddress, Web3j web3j, Credentials credentials) {
28-
super(contractAddress, web3j, credentials);
27+
private Fibonacci(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
28+
super(contractAddress, web3j, credentials, gasPrice, gasLimit);
2929
}
3030

3131
public Future<TransactionReceipt> fibonacciNotify(Uint256 number) {
@@ -47,11 +47,11 @@ public EventValues processNotifyEvent(TransactionReceipt transactionReceipt) {
4747
return extractEventParameters(event, transactionReceipt);
4848
}
4949

50-
public static Future<Fibonacci> deploy(Web3j web3j, Credentials credentials, BigInteger initialValue) {
51-
return deployAsync(Fibonacci.class, web3j, credentials, BINARY, "", initialValue);
50+
public static Future<Fibonacci> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue) {
51+
return deployAsync(Fibonacci.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialValue);
5252
}
5353

54-
public static Fibonacci load(String contractAddress, Web3j web3j, Credentials credentials) {
55-
return new Fibonacci(contractAddress, web3j, credentials);
54+
public static Fibonacci load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
55+
return new Fibonacci(contractAddress, web3j, credentials, gasPrice, gasLimit);
5656
}
5757
}

src/integration-test/java/org/web3j/generated/Greeter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
public final class Greeter extends Contract {
2424
private static final String BINARY = "606060405260405161026938038061026983398101604052805101600080546c0100000000000000000000000033810204600160a060020a03199091161790558060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1060b357805160ff19168380011785555b5060a29291505b8082111560e057600081556001016090565b505050610185806100e46000396000f35b828001600101855582156089579182015b82811115608957825182600050559160200191906001019060c4565b509056606060405260e060020a600035046341c0e1b58114610029578063cfae321714610070575b610002565b34610002576100de6000543373ffffffffffffffffffffffffffffffffffffffff9081169116141561014e5760005473ffffffffffffffffffffffffffffffffffffffff16ff5b3461000257604080516020808201835260008252600180548451600282841615610100026000190190921691909104601f81018490048402820184019095528481526100e094909283018282801561017b5780601f106101505761010080835404028352916020019161017b565b005b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156101405780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b565b820191906000526020600020905b81548152906001019060200180831161015e57829003601f168201915b505050505090509056";
2525

26-
private Greeter(String contractAddress, Web3j web3j, Credentials credentials) {
27-
super(contractAddress, web3j, credentials);
26+
private Greeter(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
27+
super(contractAddress, web3j, credentials, gasPrice, gasLimit);
2828
}
2929

3030
public Future<TransactionReceipt> kill() {
@@ -33,18 +33,18 @@ public Future<TransactionReceipt> kill() {
3333
}
3434

3535
public Future<Utf8String> greet() {
36-
Function function = new Function<Utf8String>("greet",
37-
Arrays.<Type>asList(),
36+
Function function = new Function<Utf8String>("greet",
37+
Arrays.<Type>asList(),
3838
Arrays.<TypeReference<Utf8String>>asList(new TypeReference<Utf8String>() {}));
3939
return executeCallSingleValueReturnAsync(function);
4040
}
4141

42-
public static Future<Greeter> deploy(Web3j web3j, Credentials credentials, BigInteger initialValue, Utf8String _greeting) {
42+
public static Future<Greeter> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue, Utf8String _greeting) {
4343
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(_greeting));
44-
return deployAsync(Greeter.class, web3j, credentials, BINARY, encodedConstructor, initialValue);
44+
return deployAsync(Greeter.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialValue);
4545
}
4646

47-
public static Greeter load(String contractAddress, Web3j web3j, Credentials credentials) {
48-
return new Greeter(contractAddress, web3j, credentials);
47+
public static Greeter load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
48+
return new Greeter(contractAddress, web3j, credentials, gasPrice, gasLimit);
4949
}
5050
}

0 commit comments

Comments
 (0)