diff --git a/pom.xml b/pom.xml
index f0cb72e4d0..750c95679c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,6 +74,7 @@
dozer
ethereumj
+ web3j
diff --git a/web3j/.gitignore b/web3j/.gitignore
new file mode 100644
index 0000000000..f83e8cf07c
--- /dev/null
+++ b/web3j/.gitignore
@@ -0,0 +1,3 @@
+.idea
+target
+*.iml
diff --git a/web3j/README.md b/web3j/README.md
new file mode 100644
index 0000000000..bc9909af25
--- /dev/null
+++ b/web3j/README.md
@@ -0,0 +1,4 @@
+## Web3j
+
+### Relevant Articles:
+- [Lightweight Web3](http://www.baeldung.com/lightweight-web3/)
diff --git a/web3j/dev_ganache/README.md b/web3j/dev_ganache/README.md
new file mode 100644
index 0000000000..2d3e645504
--- /dev/null
+++ b/web3j/dev_ganache/README.md
@@ -0,0 +1,23 @@
+# Ganache Readme
+
+TL:DR - To set up Ganache visit: http://truffleframework.com/ganache/
+
+# Three Ways to Install Ganache
+
+Ganache is provided in three libraries or distributions:
+
+(1) Ganache - https://github.com/trufflesuite/ganache
+
+This is a pre-built and out-of-the-box solution. Easiest to set up. It provides an interface and server shell for Ganache CLI.
+
+(2) Ganache CLI - https://www.npmjs.com/package/ganache-cli
+
+Ganache CLI abstracts Ganache Core and supplies the default options and arguments used.
+
+(3) Ganache Core - https://www.npmjs.com/package/ganache-core
+
+Basically, only use Ganache Core if you need to build a totally customized option.
+
+# Use
+
+The default port is *8545* on *localhost*
\ No newline at end of file
diff --git a/web3j/dev_truffle/README.md b/web3j/dev_truffle/README.md
new file mode 100644
index 0000000000..b64e16d570
--- /dev/null
+++ b/web3j/dev_truffle/README.md
@@ -0,0 +1,43 @@
+# Using Truffle
+
+Basic Truffle walkthrough readme.
+
+See also: http://truffleframework.com/docs/
+
+# Bash
+
+Truffle install
+
+```bash
+ $ npm install truffle -g
+ $ truffle version
+```
+
+Truffle commands:
+
+```bash
+ $ truffle init
+ $ truffle compile
+ $ truffle migrate
+ $ truffle test
+```
+
+# Directory Structure
+
+The command `$ truffle init` will create a directory structure in the specified root according to the following:
+
+```
+root -|
+ |-build (Compiled Solc JSON Output Dir)
+ |-contracts (Solc Contracts to be Compiled and Migrated)
+ |-migrations (Specify the Order and Dependencies of Contracts to Be Deployed)
+ |-test (Truffle Tests)
+```
+
+# Compile
+
+Truffle will compile the smart contracts and expose their **JSON ABI's for use with Web3.js** or **Binary ABI's for use with Web3J**.
+
+# Migration
+
+Truffle will let you deploy your Solc contracts directly to a blockchin of your choice.
\ No newline at end of file
diff --git a/web3j/dev_truffle/build/contracts/ConvertLib.json b/web3j/dev_truffle/build/contracts/ConvertLib.json
new file mode 100644
index 0000000000..977928c756
--- /dev/null
+++ b/web3j/dev_truffle/build/contracts/ConvertLib.json
@@ -0,0 +1,455 @@
+{
+ "contractName": "ConvertLib",
+ "abi": [
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "amount",
+ "type": "uint256"
+ },
+ {
+ "name": "conversionRate",
+ "type": "uint256"
+ }
+ ],
+ "name": "convert",
+ "outputs": [
+ {
+ "name": "convertedAmount",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }
+ ],
+ "bytecode": "0x60d161002f600b82828239805160001a6073146000811461001f57610021565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146060604052600436106056576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806396e4ee3d14605b575b600080fd5b8115606557600080fd5b608260048080359060200190919080359060200190919050506098565b6040518082815260200191505060405180910390f35b60008183029050929150505600a165627a7a72305820ab84b2740847d7b84a33de9738ae9cf9aabac1b68e6a64d60bd5020b9b6235e40029",
+ "deployedBytecode": "0x73000000000000000000000000000000000000000030146060604052600436106056576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806396e4ee3d14605b575b600080fd5b8115606557600080fd5b608260048080359060200190919080359060200190919050506098565b6040518082815260200191505060405180910390f35b60008183029050929150505600a165627a7a72305820ab84b2740847d7b84a33de9738ae9cf9aabac1b68e6a64d60bd5020b9b6235e40029",
+ "sourceMap": "28:148:0:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24",
+ "deployedSourceMap": "28:148:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;50:123;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;109:20;154:14;145:6;:23;138:30;;50:123;;;;:::o",
+ "source": "pragma solidity ^0.4.17;\r\n\r\nlibrary ConvertLib{\r\n\tfunction convert(uint amount,uint conversionRate) returns (uint convertedAmount)\r\n\t{\r\n\t\treturn amount * conversionRate;\r\n\t}\r\n}\r\n",
+ "sourcePath": "C:\\workspace\\current_workspace\\web3java\\dev_truffle\\contracts\\ConvertLib.sol",
+ "ast": {
+ "absolutePath": "/C/workspace/current_workspace/web3java/dev_truffle/contracts/ConvertLib.sol",
+ "exportedSymbols": {
+ "ConvertLib": [
+ 16
+ ]
+ },
+ "id": 17,
+ "nodeType": "SourceUnit",
+ "nodes": [
+ {
+ "id": 1,
+ "literals": [
+ "solidity",
+ "^",
+ "0.4",
+ ".17"
+ ],
+ "nodeType": "PragmaDirective",
+ "src": "0:24:0"
+ },
+ {
+ "baseContracts": [],
+ "contractDependencies": [],
+ "contractKind": "library",
+ "documentation": null,
+ "fullyImplemented": true,
+ "id": 16,
+ "linearizedBaseContracts": [
+ 16
+ ],
+ "name": "ConvertLib",
+ "nodeType": "ContractDefinition",
+ "nodes": [
+ {
+ "body": {
+ "id": 14,
+ "nodeType": "Block",
+ "src": "133:40:0",
+ "statements": [
+ {
+ "expression": {
+ "argumentTypes": null,
+ "commonType": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "id": 12,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "leftExpression": {
+ "argumentTypes": null,
+ "id": 10,
+ "name": "amount",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 3,
+ "src": "145:6:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "nodeType": "BinaryOperation",
+ "operator": "*",
+ "rightExpression": {
+ "argumentTypes": null,
+ "id": 11,
+ "name": "conversionRate",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 5,
+ "src": "154:14:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "src": "145:23:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "functionReturnParameters": 9,
+ "id": 13,
+ "nodeType": "Return",
+ "src": "138:30:0"
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 15,
+ "implemented": true,
+ "isConstructor": false,
+ "isDeclaredConst": false,
+ "modifiers": [],
+ "name": "convert",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 6,
+ "nodeType": "ParameterList",
+ "parameters": [
+ {
+ "constant": false,
+ "id": 3,
+ "name": "amount",
+ "nodeType": "VariableDeclaration",
+ "scope": 15,
+ "src": "67:11:0",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 2,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "67:4:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ },
+ {
+ "constant": false,
+ "id": 5,
+ "name": "conversionRate",
+ "nodeType": "VariableDeclaration",
+ "scope": 15,
+ "src": "79:19:0",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 4,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "79:4:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "src": "66:33:0"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 9,
+ "nodeType": "ParameterList",
+ "parameters": [
+ {
+ "constant": false,
+ "id": 8,
+ "name": "convertedAmount",
+ "nodeType": "VariableDeclaration",
+ "scope": 15,
+ "src": "109:20:0",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 7,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "109:4:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "src": "108:22:0"
+ },
+ "scope": 16,
+ "src": "50:123:0",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ }
+ ],
+ "scope": 17,
+ "src": "28:148:0"
+ }
+ ],
+ "src": "0:178:0"
+ },
+ "legacyAST": {
+ "absolutePath": "/C/workspace/current_workspace/web3java/dev_truffle/contracts/ConvertLib.sol",
+ "exportedSymbols": {
+ "ConvertLib": [
+ 16
+ ]
+ },
+ "id": 17,
+ "nodeType": "SourceUnit",
+ "nodes": [
+ {
+ "id": 1,
+ "literals": [
+ "solidity",
+ "^",
+ "0.4",
+ ".17"
+ ],
+ "nodeType": "PragmaDirective",
+ "src": "0:24:0"
+ },
+ {
+ "baseContracts": [],
+ "contractDependencies": [],
+ "contractKind": "library",
+ "documentation": null,
+ "fullyImplemented": true,
+ "id": 16,
+ "linearizedBaseContracts": [
+ 16
+ ],
+ "name": "ConvertLib",
+ "nodeType": "ContractDefinition",
+ "nodes": [
+ {
+ "body": {
+ "id": 14,
+ "nodeType": "Block",
+ "src": "133:40:0",
+ "statements": [
+ {
+ "expression": {
+ "argumentTypes": null,
+ "commonType": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "id": 12,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "leftExpression": {
+ "argumentTypes": null,
+ "id": 10,
+ "name": "amount",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 3,
+ "src": "145:6:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "nodeType": "BinaryOperation",
+ "operator": "*",
+ "rightExpression": {
+ "argumentTypes": null,
+ "id": 11,
+ "name": "conversionRate",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 5,
+ "src": "154:14:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "src": "145:23:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "functionReturnParameters": 9,
+ "id": 13,
+ "nodeType": "Return",
+ "src": "138:30:0"
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 15,
+ "implemented": true,
+ "isConstructor": false,
+ "isDeclaredConst": false,
+ "modifiers": [],
+ "name": "convert",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 6,
+ "nodeType": "ParameterList",
+ "parameters": [
+ {
+ "constant": false,
+ "id": 3,
+ "name": "amount",
+ "nodeType": "VariableDeclaration",
+ "scope": 15,
+ "src": "67:11:0",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 2,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "67:4:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ },
+ {
+ "constant": false,
+ "id": 5,
+ "name": "conversionRate",
+ "nodeType": "VariableDeclaration",
+ "scope": 15,
+ "src": "79:19:0",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 4,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "79:4:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "src": "66:33:0"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 9,
+ "nodeType": "ParameterList",
+ "parameters": [
+ {
+ "constant": false,
+ "id": 8,
+ "name": "convertedAmount",
+ "nodeType": "VariableDeclaration",
+ "scope": 15,
+ "src": "109:20:0",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 7,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "109:4:0",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "src": "108:22:0"
+ },
+ "scope": 16,
+ "src": "50:123:0",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ }
+ ],
+ "scope": 17,
+ "src": "28:148:0"
+ }
+ ],
+ "src": "0:178:0"
+ },
+ "compiler": {
+ "name": "solc",
+ "version": "0.4.21+commit.dfe3193c.Emscripten.clang"
+ },
+ "networks": {},
+ "schemaVersion": "2.0.0",
+ "updatedAt": "2018-04-14T03:37:39.678Z"
+}
\ No newline at end of file
diff --git a/web3j/dev_truffle/build/contracts/Example.json b/web3j/dev_truffle/build/contracts/Example.json
new file mode 100644
index 0000000000..82111dab11
--- /dev/null
+++ b/web3j/dev_truffle/build/contracts/Example.json
@@ -0,0 +1,251 @@
+{
+ "contractName": "Example",
+ "abi": [
+ {
+ "inputs": [],
+ "payable": false,
+ "stateMutability": "nonpayable",
+ "type": "constructor"
+ },
+ {
+ "constant": false,
+ "inputs": [],
+ "name": "ExampleFunction",
+ "outputs": [],
+ "payable": false,
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }
+ ],
+ "bytecode": "0x60606040523415600e57600080fd5b60848061001c6000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063b818dacd146044575b600080fd5b3415604e57600080fd5b60546056565b005b5600a165627a7a72305820bebcbbdf06550591bc772dfcb0eadc842f95953869feb7a9528bac91487d95240029",
+ "deployedBytecode": "0x606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063b818dacd146044575b600080fd5b3415604e57600080fd5b60546056565b005b5600a165627a7a72305820bebcbbdf06550591bc772dfcb0eadc842f95953869feb7a9528bac91487d95240029",
+ "sourceMap": "28:134:1:-;;;50:45;;;;;;;;28:134;;;;;;",
+ "deployedSourceMap": "28:134:1:-;;;;;;;;;;;;;;;;;;;;;;;;101:58;;;;;;;;;;;;;;;:::o",
+ "source": "pragma solidity ^0.4.17;\r\n\r\ncontract Example {\r\n function Example() {\r\n // constructor\r\n }\r\n\r\n function ExampleFunction() {\r\n // example function\r\n }\r\n}",
+ "sourcePath": "C:\\workspace\\current_workspace\\web3java\\dev_truffle\\contracts\\Example.sol",
+ "ast": {
+ "absolutePath": "/C/workspace/current_workspace/web3java/dev_truffle/contracts/Example.sol",
+ "exportedSymbols": {
+ "Example": [
+ 27
+ ]
+ },
+ "id": 28,
+ "nodeType": "SourceUnit",
+ "nodes": [
+ {
+ "id": 18,
+ "literals": [
+ "solidity",
+ "^",
+ "0.4",
+ ".17"
+ ],
+ "nodeType": "PragmaDirective",
+ "src": "0:24:1"
+ },
+ {
+ "baseContracts": [],
+ "contractDependencies": [],
+ "contractKind": "contract",
+ "documentation": null,
+ "fullyImplemented": true,
+ "id": 27,
+ "linearizedBaseContracts": [
+ 27
+ ],
+ "name": "Example",
+ "nodeType": "ContractDefinition",
+ "nodes": [
+ {
+ "body": {
+ "id": 21,
+ "nodeType": "Block",
+ "src": "69:26:1",
+ "statements": []
+ },
+ "documentation": null,
+ "id": 22,
+ "implemented": true,
+ "isConstructor": true,
+ "isDeclaredConst": false,
+ "modifiers": [],
+ "name": "Example",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 19,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "66:2:1"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 20,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "69:0:1"
+ },
+ "scope": 27,
+ "src": "50:45:1",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ },
+ {
+ "body": {
+ "id": 25,
+ "nodeType": "Block",
+ "src": "128:31:1",
+ "statements": []
+ },
+ "documentation": null,
+ "id": 26,
+ "implemented": true,
+ "isConstructor": false,
+ "isDeclaredConst": false,
+ "modifiers": [],
+ "name": "ExampleFunction",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 23,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "125:2:1"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 24,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "128:0:1"
+ },
+ "scope": 27,
+ "src": "101:58:1",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ }
+ ],
+ "scope": 28,
+ "src": "28:134:1"
+ }
+ ],
+ "src": "0:162:1"
+ },
+ "legacyAST": {
+ "absolutePath": "/C/workspace/current_workspace/web3java/dev_truffle/contracts/Example.sol",
+ "exportedSymbols": {
+ "Example": [
+ 27
+ ]
+ },
+ "id": 28,
+ "nodeType": "SourceUnit",
+ "nodes": [
+ {
+ "id": 18,
+ "literals": [
+ "solidity",
+ "^",
+ "0.4",
+ ".17"
+ ],
+ "nodeType": "PragmaDirective",
+ "src": "0:24:1"
+ },
+ {
+ "baseContracts": [],
+ "contractDependencies": [],
+ "contractKind": "contract",
+ "documentation": null,
+ "fullyImplemented": true,
+ "id": 27,
+ "linearizedBaseContracts": [
+ 27
+ ],
+ "name": "Example",
+ "nodeType": "ContractDefinition",
+ "nodes": [
+ {
+ "body": {
+ "id": 21,
+ "nodeType": "Block",
+ "src": "69:26:1",
+ "statements": []
+ },
+ "documentation": null,
+ "id": 22,
+ "implemented": true,
+ "isConstructor": true,
+ "isDeclaredConst": false,
+ "modifiers": [],
+ "name": "Example",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 19,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "66:2:1"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 20,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "69:0:1"
+ },
+ "scope": 27,
+ "src": "50:45:1",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ },
+ {
+ "body": {
+ "id": 25,
+ "nodeType": "Block",
+ "src": "128:31:1",
+ "statements": []
+ },
+ "documentation": null,
+ "id": 26,
+ "implemented": true,
+ "isConstructor": false,
+ "isDeclaredConst": false,
+ "modifiers": [],
+ "name": "ExampleFunction",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 23,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "125:2:1"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 24,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "128:0:1"
+ },
+ "scope": 27,
+ "src": "101:58:1",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ }
+ ],
+ "scope": 28,
+ "src": "28:134:1"
+ }
+ ],
+ "src": "0:162:1"
+ },
+ "compiler": {
+ "name": "solc",
+ "version": "0.4.21+commit.dfe3193c.Emscripten.clang"
+ },
+ "networks": {},
+ "schemaVersion": "2.0.0",
+ "updatedAt": "2018-04-14T03:37:39.710Z"
+}
\ No newline at end of file
diff --git a/web3j/dev_truffle/build/contracts/Migrations.json b/web3j/dev_truffle/build/contracts/Migrations.json
new file mode 100644
index 0000000000..55f2c7ad69
--- /dev/null
+++ b/web3j/dev_truffle/build/contracts/Migrations.json
@@ -0,0 +1,1380 @@
+{
+ "contractName": "Migrations",
+ "abi": [
+ {
+ "constant": true,
+ "inputs": [],
+ "name": "last_completed_migration",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [],
+ "name": "owner",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "payable": false,
+ "stateMutability": "nonpayable",
+ "type": "constructor"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "completed",
+ "type": "uint256"
+ }
+ ],
+ "name": "setCompleted",
+ "outputs": [],
+ "payable": false,
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "new_address",
+ "type": "address"
+ }
+ ],
+ "name": "upgrade",
+ "outputs": [],
+ "payable": false,
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }
+ ],
+ "bytecode": "0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102d78061005e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610220565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc610226565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024b565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561021c578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b5af1151561021857600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102a857806001819055505b505600a165627a7a72305820be5431ce1823a03470fc4376ec6fdfa9e54ca2bd2b05b6271c73eb54ad4e4b060029",
+ "deployedBytecode": "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610220565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc610226565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024b565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561021c578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b5af1151561021857600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102a857806001819055505b505600a165627a7a72305820be5431ce1823a03470fc4376ec6fdfa9e54ca2bd2b05b6271c73eb54ad4e4b060029",
+ "sourceMap": "26:488:2:-;;;178:58;;;;;;;;221:10;213:5;;:18;;;;;;;;;;;;;;;;;;26:488;;;;;;",
+ "deployedSourceMap": "26:488:2:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;;;;;;;;;;;;;;;;;;;;;;;;;;;;74:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;50:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;240:103;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;409:19;161:5;;;;;;;;;;;147:19;;:10;:19;;;143:26;;;442:11;409:45;;460:8;:21;;;482:24;;460:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;143:26;347:165;;:::o;74:36::-;;;;:::o;50:20::-;;;;;;;;;;;;;:::o;240:103::-;161:5;;;;;;;;;;;147:19;;:10;:19;;;143:26;;;329:9;302:24;:36;;;;143:26;240:103;:::o",
+ "source": "pragma solidity ^0.4.17;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function Migrations() public {\n owner = msg.sender;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n",
+ "sourcePath": "C:\\workspace\\current_workspace\\web3java\\dev_truffle\\contracts\\Migrations.sol",
+ "ast": {
+ "absolutePath": "/C/workspace/current_workspace/web3java/dev_truffle/contracts/Migrations.sol",
+ "exportedSymbols": {
+ "Migrations": [
+ 84
+ ]
+ },
+ "id": 85,
+ "nodeType": "SourceUnit",
+ "nodes": [
+ {
+ "id": 29,
+ "literals": [
+ "solidity",
+ "^",
+ "0.4",
+ ".17"
+ ],
+ "nodeType": "PragmaDirective",
+ "src": "0:24:2"
+ },
+ {
+ "baseContracts": [],
+ "contractDependencies": [],
+ "contractKind": "contract",
+ "documentation": null,
+ "fullyImplemented": true,
+ "id": 84,
+ "linearizedBaseContracts": [
+ 84
+ ],
+ "name": "Migrations",
+ "nodeType": "ContractDefinition",
+ "nodes": [
+ {
+ "constant": false,
+ "id": 31,
+ "name": "owner",
+ "nodeType": "VariableDeclaration",
+ "scope": 84,
+ "src": "50:20:2",
+ "stateVariable": true,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ },
+ "typeName": {
+ "id": 30,
+ "name": "address",
+ "nodeType": "ElementaryTypeName",
+ "src": "50:7:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "value": null,
+ "visibility": "public"
+ },
+ {
+ "constant": false,
+ "id": 33,
+ "name": "last_completed_migration",
+ "nodeType": "VariableDeclaration",
+ "scope": 84,
+ "src": "74:36:2",
+ "stateVariable": true,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 32,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "74:4:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "public"
+ },
+ {
+ "body": {
+ "id": 41,
+ "nodeType": "Block",
+ "src": "137:37:2",
+ "statements": [
+ {
+ "condition": {
+ "argumentTypes": null,
+ "commonType": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ },
+ "id": 38,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "leftExpression": {
+ "argumentTypes": null,
+ "expression": {
+ "argumentTypes": null,
+ "id": 35,
+ "name": "msg",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 97,
+ "src": "147:3:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_magic_message",
+ "typeString": "msg"
+ }
+ },
+ "id": 36,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "memberName": "sender",
+ "nodeType": "MemberAccess",
+ "referencedDeclaration": null,
+ "src": "147:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "nodeType": "BinaryOperation",
+ "operator": "==",
+ "rightExpression": {
+ "argumentTypes": null,
+ "id": 37,
+ "name": "owner",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 31,
+ "src": "161:5:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "src": "147:19:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_bool",
+ "typeString": "bool"
+ }
+ },
+ "falseBody": null,
+ "id": 40,
+ "nodeType": "IfStatement",
+ "src": "143:26:2",
+ "trueBody": {
+ "id": 39,
+ "nodeType": "PlaceholderStatement",
+ "src": "168:1:2"
+ }
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 42,
+ "name": "restricted",
+ "nodeType": "ModifierDefinition",
+ "parameters": {
+ "id": 34,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "134:2:2"
+ },
+ "src": "115:59:2",
+ "visibility": "internal"
+ },
+ {
+ "body": {
+ "id": 50,
+ "nodeType": "Block",
+ "src": "207:29:2",
+ "statements": [
+ {
+ "expression": {
+ "argumentTypes": null,
+ "id": 48,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "leftHandSide": {
+ "argumentTypes": null,
+ "id": 45,
+ "name": "owner",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 31,
+ "src": "213:5:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "nodeType": "Assignment",
+ "operator": "=",
+ "rightHandSide": {
+ "argumentTypes": null,
+ "expression": {
+ "argumentTypes": null,
+ "id": 46,
+ "name": "msg",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 97,
+ "src": "221:3:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_magic_message",
+ "typeString": "msg"
+ }
+ },
+ "id": 47,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "memberName": "sender",
+ "nodeType": "MemberAccess",
+ "referencedDeclaration": null,
+ "src": "221:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "src": "213:18:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "id": 49,
+ "nodeType": "ExpressionStatement",
+ "src": "213:18:2"
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 51,
+ "implemented": true,
+ "isConstructor": true,
+ "isDeclaredConst": false,
+ "modifiers": [],
+ "name": "Migrations",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 43,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "197:2:2"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 44,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "207:0:2"
+ },
+ "scope": 84,
+ "src": "178:58:2",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ },
+ {
+ "body": {
+ "id": 62,
+ "nodeType": "Block",
+ "src": "296:47:2",
+ "statements": [
+ {
+ "expression": {
+ "argumentTypes": null,
+ "id": 60,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "leftHandSide": {
+ "argumentTypes": null,
+ "id": 58,
+ "name": "last_completed_migration",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 33,
+ "src": "302:24:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "nodeType": "Assignment",
+ "operator": "=",
+ "rightHandSide": {
+ "argumentTypes": null,
+ "id": 59,
+ "name": "completed",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 53,
+ "src": "329:9:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "src": "302:36:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "id": 61,
+ "nodeType": "ExpressionStatement",
+ "src": "302:36:2"
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 63,
+ "implemented": true,
+ "isConstructor": false,
+ "isDeclaredConst": false,
+ "modifiers": [
+ {
+ "arguments": [],
+ "id": 56,
+ "modifierName": {
+ "argumentTypes": null,
+ "id": 55,
+ "name": "restricted",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 42,
+ "src": "285:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_modifier$__$",
+ "typeString": "modifier ()"
+ }
+ },
+ "nodeType": "ModifierInvocation",
+ "src": "285:10:2"
+ }
+ ],
+ "name": "setCompleted",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 54,
+ "nodeType": "ParameterList",
+ "parameters": [
+ {
+ "constant": false,
+ "id": 53,
+ "name": "completed",
+ "nodeType": "VariableDeclaration",
+ "scope": 63,
+ "src": "262:14:2",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 52,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "262:4:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "src": "261:16:2"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 57,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "296:0:2"
+ },
+ "scope": 84,
+ "src": "240:103:2",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ },
+ {
+ "body": {
+ "id": 82,
+ "nodeType": "Block",
+ "src": "403:109:2",
+ "statements": [
+ {
+ "assignments": [
+ 71
+ ],
+ "declarations": [
+ {
+ "constant": false,
+ "id": 71,
+ "name": "upgraded",
+ "nodeType": "VariableDeclaration",
+ "scope": 83,
+ "src": "409:19:2",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_contract$_Migrations_$84",
+ "typeString": "contract Migrations"
+ },
+ "typeName": {
+ "contractScope": null,
+ "id": 70,
+ "name": "Migrations",
+ "nodeType": "UserDefinedTypeName",
+ "referencedDeclaration": 84,
+ "src": "409:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_contract$_Migrations_$84",
+ "typeString": "contract Migrations"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "id": 75,
+ "initialValue": {
+ "argumentTypes": null,
+ "arguments": [
+ {
+ "argumentTypes": null,
+ "id": 73,
+ "name": "new_address",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 65,
+ "src": "442:11:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ }
+ ],
+ "expression": {
+ "argumentTypes": [
+ {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ ],
+ "id": 72,
+ "name": "Migrations",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 84,
+ "src": "431:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_type$_t_contract$_Migrations_$84_$",
+ "typeString": "type(contract Migrations)"
+ }
+ },
+ "id": 74,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "kind": "typeConversion",
+ "lValueRequested": false,
+ "names": [],
+ "nodeType": "FunctionCall",
+ "src": "431:23:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_contract$_Migrations_$84",
+ "typeString": "contract Migrations"
+ }
+ },
+ "nodeType": "VariableDeclarationStatement",
+ "src": "409:45:2"
+ },
+ {
+ "expression": {
+ "argumentTypes": null,
+ "arguments": [
+ {
+ "argumentTypes": null,
+ "id": 79,
+ "name": "last_completed_migration",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 33,
+ "src": "482:24:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ }
+ ],
+ "expression": {
+ "argumentTypes": [
+ {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ ],
+ "expression": {
+ "argumentTypes": null,
+ "id": 76,
+ "name": "upgraded",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 71,
+ "src": "460:8:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_contract$_Migrations_$84",
+ "typeString": "contract Migrations"
+ }
+ },
+ "id": 78,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "memberName": "setCompleted",
+ "nodeType": "MemberAccess",
+ "referencedDeclaration": 63,
+ "src": "460:21:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$",
+ "typeString": "function (uint256) external"
+ }
+ },
+ "id": 80,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "kind": "functionCall",
+ "lValueRequested": false,
+ "names": [],
+ "nodeType": "FunctionCall",
+ "src": "460:47:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_tuple$__$",
+ "typeString": "tuple()"
+ }
+ },
+ "id": 81,
+ "nodeType": "ExpressionStatement",
+ "src": "460:47:2"
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 83,
+ "implemented": true,
+ "isConstructor": false,
+ "isDeclaredConst": false,
+ "modifiers": [
+ {
+ "arguments": [],
+ "id": 68,
+ "modifierName": {
+ "argumentTypes": null,
+ "id": 67,
+ "name": "restricted",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 42,
+ "src": "392:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_modifier$__$",
+ "typeString": "modifier ()"
+ }
+ },
+ "nodeType": "ModifierInvocation",
+ "src": "392:10:2"
+ }
+ ],
+ "name": "upgrade",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 66,
+ "nodeType": "ParameterList",
+ "parameters": [
+ {
+ "constant": false,
+ "id": 65,
+ "name": "new_address",
+ "nodeType": "VariableDeclaration",
+ "scope": 83,
+ "src": "364:19:2",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ },
+ "typeName": {
+ "id": 64,
+ "name": "address",
+ "nodeType": "ElementaryTypeName",
+ "src": "364:7:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "src": "363:21:2"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 69,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "403:0:2"
+ },
+ "scope": 84,
+ "src": "347:165:2",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ }
+ ],
+ "scope": 85,
+ "src": "26:488:2"
+ }
+ ],
+ "src": "0:515:2"
+ },
+ "legacyAST": {
+ "absolutePath": "/C/workspace/current_workspace/web3java/dev_truffle/contracts/Migrations.sol",
+ "exportedSymbols": {
+ "Migrations": [
+ 84
+ ]
+ },
+ "id": 85,
+ "nodeType": "SourceUnit",
+ "nodes": [
+ {
+ "id": 29,
+ "literals": [
+ "solidity",
+ "^",
+ "0.4",
+ ".17"
+ ],
+ "nodeType": "PragmaDirective",
+ "src": "0:24:2"
+ },
+ {
+ "baseContracts": [],
+ "contractDependencies": [],
+ "contractKind": "contract",
+ "documentation": null,
+ "fullyImplemented": true,
+ "id": 84,
+ "linearizedBaseContracts": [
+ 84
+ ],
+ "name": "Migrations",
+ "nodeType": "ContractDefinition",
+ "nodes": [
+ {
+ "constant": false,
+ "id": 31,
+ "name": "owner",
+ "nodeType": "VariableDeclaration",
+ "scope": 84,
+ "src": "50:20:2",
+ "stateVariable": true,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ },
+ "typeName": {
+ "id": 30,
+ "name": "address",
+ "nodeType": "ElementaryTypeName",
+ "src": "50:7:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "value": null,
+ "visibility": "public"
+ },
+ {
+ "constant": false,
+ "id": 33,
+ "name": "last_completed_migration",
+ "nodeType": "VariableDeclaration",
+ "scope": 84,
+ "src": "74:36:2",
+ "stateVariable": true,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 32,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "74:4:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "public"
+ },
+ {
+ "body": {
+ "id": 41,
+ "nodeType": "Block",
+ "src": "137:37:2",
+ "statements": [
+ {
+ "condition": {
+ "argumentTypes": null,
+ "commonType": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ },
+ "id": 38,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "leftExpression": {
+ "argumentTypes": null,
+ "expression": {
+ "argumentTypes": null,
+ "id": 35,
+ "name": "msg",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 97,
+ "src": "147:3:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_magic_message",
+ "typeString": "msg"
+ }
+ },
+ "id": 36,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "memberName": "sender",
+ "nodeType": "MemberAccess",
+ "referencedDeclaration": null,
+ "src": "147:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "nodeType": "BinaryOperation",
+ "operator": "==",
+ "rightExpression": {
+ "argumentTypes": null,
+ "id": 37,
+ "name": "owner",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 31,
+ "src": "161:5:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "src": "147:19:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_bool",
+ "typeString": "bool"
+ }
+ },
+ "falseBody": null,
+ "id": 40,
+ "nodeType": "IfStatement",
+ "src": "143:26:2",
+ "trueBody": {
+ "id": 39,
+ "nodeType": "PlaceholderStatement",
+ "src": "168:1:2"
+ }
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 42,
+ "name": "restricted",
+ "nodeType": "ModifierDefinition",
+ "parameters": {
+ "id": 34,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "134:2:2"
+ },
+ "src": "115:59:2",
+ "visibility": "internal"
+ },
+ {
+ "body": {
+ "id": 50,
+ "nodeType": "Block",
+ "src": "207:29:2",
+ "statements": [
+ {
+ "expression": {
+ "argumentTypes": null,
+ "id": 48,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "leftHandSide": {
+ "argumentTypes": null,
+ "id": 45,
+ "name": "owner",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 31,
+ "src": "213:5:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "nodeType": "Assignment",
+ "operator": "=",
+ "rightHandSide": {
+ "argumentTypes": null,
+ "expression": {
+ "argumentTypes": null,
+ "id": 46,
+ "name": "msg",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 97,
+ "src": "221:3:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_magic_message",
+ "typeString": "msg"
+ }
+ },
+ "id": 47,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "memberName": "sender",
+ "nodeType": "MemberAccess",
+ "referencedDeclaration": null,
+ "src": "221:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "src": "213:18:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "id": 49,
+ "nodeType": "ExpressionStatement",
+ "src": "213:18:2"
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 51,
+ "implemented": true,
+ "isConstructor": true,
+ "isDeclaredConst": false,
+ "modifiers": [],
+ "name": "Migrations",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 43,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "197:2:2"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 44,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "207:0:2"
+ },
+ "scope": 84,
+ "src": "178:58:2",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ },
+ {
+ "body": {
+ "id": 62,
+ "nodeType": "Block",
+ "src": "296:47:2",
+ "statements": [
+ {
+ "expression": {
+ "argumentTypes": null,
+ "id": 60,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "leftHandSide": {
+ "argumentTypes": null,
+ "id": 58,
+ "name": "last_completed_migration",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 33,
+ "src": "302:24:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "nodeType": "Assignment",
+ "operator": "=",
+ "rightHandSide": {
+ "argumentTypes": null,
+ "id": 59,
+ "name": "completed",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 53,
+ "src": "329:9:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "src": "302:36:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "id": 61,
+ "nodeType": "ExpressionStatement",
+ "src": "302:36:2"
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 63,
+ "implemented": true,
+ "isConstructor": false,
+ "isDeclaredConst": false,
+ "modifiers": [
+ {
+ "arguments": [],
+ "id": 56,
+ "modifierName": {
+ "argumentTypes": null,
+ "id": 55,
+ "name": "restricted",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 42,
+ "src": "285:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_modifier$__$",
+ "typeString": "modifier ()"
+ }
+ },
+ "nodeType": "ModifierInvocation",
+ "src": "285:10:2"
+ }
+ ],
+ "name": "setCompleted",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 54,
+ "nodeType": "ParameterList",
+ "parameters": [
+ {
+ "constant": false,
+ "id": 53,
+ "name": "completed",
+ "nodeType": "VariableDeclaration",
+ "scope": 63,
+ "src": "262:14:2",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ },
+ "typeName": {
+ "id": 52,
+ "name": "uint",
+ "nodeType": "ElementaryTypeName",
+ "src": "262:4:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "src": "261:16:2"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 57,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "296:0:2"
+ },
+ "scope": 84,
+ "src": "240:103:2",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ },
+ {
+ "body": {
+ "id": 82,
+ "nodeType": "Block",
+ "src": "403:109:2",
+ "statements": [
+ {
+ "assignments": [
+ 71
+ ],
+ "declarations": [
+ {
+ "constant": false,
+ "id": 71,
+ "name": "upgraded",
+ "nodeType": "VariableDeclaration",
+ "scope": 83,
+ "src": "409:19:2",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_contract$_Migrations_$84",
+ "typeString": "contract Migrations"
+ },
+ "typeName": {
+ "contractScope": null,
+ "id": 70,
+ "name": "Migrations",
+ "nodeType": "UserDefinedTypeName",
+ "referencedDeclaration": 84,
+ "src": "409:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_contract$_Migrations_$84",
+ "typeString": "contract Migrations"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "id": 75,
+ "initialValue": {
+ "argumentTypes": null,
+ "arguments": [
+ {
+ "argumentTypes": null,
+ "id": 73,
+ "name": "new_address",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 65,
+ "src": "442:11:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ }
+ ],
+ "expression": {
+ "argumentTypes": [
+ {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ ],
+ "id": 72,
+ "name": "Migrations",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 84,
+ "src": "431:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_type$_t_contract$_Migrations_$84_$",
+ "typeString": "type(contract Migrations)"
+ }
+ },
+ "id": 74,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "kind": "typeConversion",
+ "lValueRequested": false,
+ "names": [],
+ "nodeType": "FunctionCall",
+ "src": "431:23:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_contract$_Migrations_$84",
+ "typeString": "contract Migrations"
+ }
+ },
+ "nodeType": "VariableDeclarationStatement",
+ "src": "409:45:2"
+ },
+ {
+ "expression": {
+ "argumentTypes": null,
+ "arguments": [
+ {
+ "argumentTypes": null,
+ "id": 79,
+ "name": "last_completed_migration",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 33,
+ "src": "482:24:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ }
+ ],
+ "expression": {
+ "argumentTypes": [
+ {
+ "typeIdentifier": "t_uint256",
+ "typeString": "uint256"
+ }
+ ],
+ "expression": {
+ "argumentTypes": null,
+ "id": 76,
+ "name": "upgraded",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 71,
+ "src": "460:8:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_contract$_Migrations_$84",
+ "typeString": "contract Migrations"
+ }
+ },
+ "id": 78,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "lValueRequested": false,
+ "memberName": "setCompleted",
+ "nodeType": "MemberAccess",
+ "referencedDeclaration": 63,
+ "src": "460:21:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$",
+ "typeString": "function (uint256) external"
+ }
+ },
+ "id": 80,
+ "isConstant": false,
+ "isLValue": false,
+ "isPure": false,
+ "kind": "functionCall",
+ "lValueRequested": false,
+ "names": [],
+ "nodeType": "FunctionCall",
+ "src": "460:47:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_tuple$__$",
+ "typeString": "tuple()"
+ }
+ },
+ "id": 81,
+ "nodeType": "ExpressionStatement",
+ "src": "460:47:2"
+ }
+ ]
+ },
+ "documentation": null,
+ "id": 83,
+ "implemented": true,
+ "isConstructor": false,
+ "isDeclaredConst": false,
+ "modifiers": [
+ {
+ "arguments": [],
+ "id": 68,
+ "modifierName": {
+ "argumentTypes": null,
+ "id": 67,
+ "name": "restricted",
+ "nodeType": "Identifier",
+ "overloadedDeclarations": [],
+ "referencedDeclaration": 42,
+ "src": "392:10:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_modifier$__$",
+ "typeString": "modifier ()"
+ }
+ },
+ "nodeType": "ModifierInvocation",
+ "src": "392:10:2"
+ }
+ ],
+ "name": "upgrade",
+ "nodeType": "FunctionDefinition",
+ "parameters": {
+ "id": 66,
+ "nodeType": "ParameterList",
+ "parameters": [
+ {
+ "constant": false,
+ "id": 65,
+ "name": "new_address",
+ "nodeType": "VariableDeclaration",
+ "scope": 83,
+ "src": "364:19:2",
+ "stateVariable": false,
+ "storageLocation": "default",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ },
+ "typeName": {
+ "id": 64,
+ "name": "address",
+ "nodeType": "ElementaryTypeName",
+ "src": "364:7:2",
+ "typeDescriptions": {
+ "typeIdentifier": "t_address",
+ "typeString": "address"
+ }
+ },
+ "value": null,
+ "visibility": "internal"
+ }
+ ],
+ "src": "363:21:2"
+ },
+ "payable": false,
+ "returnParameters": {
+ "id": 69,
+ "nodeType": "ParameterList",
+ "parameters": [],
+ "src": "403:0:2"
+ },
+ "scope": 84,
+ "src": "347:165:2",
+ "stateMutability": "nonpayable",
+ "superFunction": null,
+ "visibility": "public"
+ }
+ ],
+ "scope": 85,
+ "src": "26:488:2"
+ }
+ ],
+ "src": "0:515:2"
+ },
+ "compiler": {
+ "name": "solc",
+ "version": "0.4.21+commit.dfe3193c.Emscripten.clang"
+ },
+ "networks": {},
+ "schemaVersion": "2.0.0",
+ "updatedAt": "2018-04-14T03:37:39.710Z"
+}
\ No newline at end of file
diff --git a/web3j/dev_truffle/contracts/ConvertLib.sol b/web3j/dev_truffle/contracts/ConvertLib.sol
new file mode 100644
index 0000000000..ec0576fc3f
--- /dev/null
+++ b/web3j/dev_truffle/contracts/ConvertLib.sol
@@ -0,0 +1,8 @@
+pragma solidity ^0.4.17;
+
+library ConvertLib{
+ function convert(uint amount,uint conversionRate) returns (uint convertedAmount)
+ {
+ return amount * conversionRate;
+ }
+}
diff --git a/web3j/dev_truffle/contracts/Example.sol b/web3j/dev_truffle/contracts/Example.sol
new file mode 100644
index 0000000000..c09c54843c
--- /dev/null
+++ b/web3j/dev_truffle/contracts/Example.sol
@@ -0,0 +1,11 @@
+pragma solidity ^0.4.17;
+
+contract Example {
+ function Example() {
+ // constructor
+ }
+
+ function ExampleFunction() {
+ // example function
+ }
+}
\ No newline at end of file
diff --git a/web3j/dev_truffle/contracts/Migrations.sol b/web3j/dev_truffle/contracts/Migrations.sol
new file mode 100644
index 0000000000..f170cb4fa7
--- /dev/null
+++ b/web3j/dev_truffle/contracts/Migrations.sol
@@ -0,0 +1,23 @@
+pragma solidity ^0.4.17;
+
+contract Migrations {
+ address public owner;
+ uint public last_completed_migration;
+
+ modifier restricted() {
+ if (msg.sender == owner) _;
+ }
+
+ function Migrations() public {
+ owner = msg.sender;
+ }
+
+ function setCompleted(uint completed) public restricted {
+ last_completed_migration = completed;
+ }
+
+ function upgrade(address new_address) public restricted {
+ Migrations upgraded = Migrations(new_address);
+ upgraded.setCompleted(last_completed_migration);
+ }
+}
diff --git a/web3j/dev_truffle/migrations/1_initial_migration.js b/web3j/dev_truffle/migrations/1_initial_migration.js
new file mode 100644
index 0000000000..269ad95867
--- /dev/null
+++ b/web3j/dev_truffle/migrations/1_initial_migration.js
@@ -0,0 +1,3 @@
+module.exports = deployer => {
+ deployer.deploy(artifacts.require("./Migrations.sol"));
+};
diff --git a/web3j/dev_truffle/migrations/2_deploy_contracts.js b/web3j/dev_truffle/migrations/2_deploy_contracts.js
new file mode 100644
index 0000000000..b6f30176ae
--- /dev/null
+++ b/web3j/dev_truffle/migrations/2_deploy_contracts.js
@@ -0,0 +1,8 @@
+const Example = artifacts.require("./Example.sol"),
+ ConvertLib = artifacts.require("./ConvertLib.sol");
+
+module.exports = deployer => {
+ deployer.deploy(ConvertLib);
+ deployer.link(ConvertLib, Example);
+ deployer.deploy(Example);
+};
diff --git a/web3j/dev_truffle/truffle.js b/web3j/dev_truffle/truffle.js
new file mode 100644
index 0000000000..8110fdad45
--- /dev/null
+++ b/web3j/dev_truffle/truffle.js
@@ -0,0 +1,20 @@
+module.exports = {
+ contracts_build_directory: "./build/contracts",
+ networks: {
+ live: {
+ network_id: 1, // Ethereum public network
+ host: 'localhost',
+ port: 8545
+ },
+ testnet: {
+ network_id: 3, // Official Ethereum test network (Ropsten)
+ host: 'localhost',
+ port: 8545
+ },
+ development: {
+ host: 'localhost',
+ port: 8545,
+ network_id: '*'
+ }
+ }
+}
diff --git a/web3j/pom.xml b/web3j/pom.xml
new file mode 100644
index 0000000000..7d2eea9047
--- /dev/null
+++ b/web3j/pom.xml
@@ -0,0 +1,210 @@
+
+
+ 4.0.0
+ com.baeldung.web3j
+ Web3j
+ war
+ 1.0.0
+ web3j
+
+
+ 1.3
+ 2.9.3
+ 2.3.1
+ 3.1.0
+ 2.4.0
+ 1.2
+ 4.12
+ 1.2.3
+ 2.18.1
+ 1.10.19
+ 1.7.25
+ 5.0.5.RELEASE
+
+
+
+
+
+ org.springframework
+ spring-core
+ ${springframework.version}
+
+
+ org.springframework
+ spring-web
+ ${springframework.version}
+
+
+ org.springframework
+ spring-webmvc
+ ${springframework.version}
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ ${javax-servlet.version}
+
+
+ javax.servlet.jsp.jstl
+ jstl-api
+ ${jstl.version}
+
+
+ javax.servlet.jsp
+ javax.servlet.jsp-api
+ ${javax-jsp.version}
+
+
+ javax.servlet
+ jstl
+ ${jstl.version}
+
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${slf4j.version}
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ ${jackson.version}
+
+
+
+
+ org.web3j
+ core
+ 3.3.1
+
+
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+
+
+ org.hamcrest
+ hamcrest-core
+
+
+ test
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-core
+
+
+
+
+ org.hamcrest
+ hamcrest-library
+ ${hamcrest.version}
+ test
+
+
+ org.springframework
+ spring-context
+ ${springframework.version}
+
+
+ org.springframework
+ spring-test
+ ${springframework.version}
+ test
+
+
+ com.jayway.jsonpath
+ json-path
+ ${jsonpath.version}
+
+
+
+
+
+
+
+ maven-compiler-plugin
+ 3.1
+
+ 1.8
+ 1.8
+
+
+
+ org.apache.tomcat.maven
+ tomcat8-maven-plugin
+ 3.0-r1655215
+
+ /javaweb3
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 3.0.0
+
+ src/main/webapp
+ false
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire.version}
+
+
+ install
+ install
+
+ test
+
+
+
+
+ test/com/baeldung/web3j/controllers/EthereumRestControllerIntegrationTest.java
+
+
+ test/com/baeldung/web3j/controllers/EthereumRestControllerUnitTest.java
+
+
+ test/com/baeldung/web3j/services/EthereumContractUnitTest.java
+
+
+
+
+
+
+
+
+ web3j
+
+
\ No newline at end of file
diff --git a/web3j/src/main/java/com/baeldung/web3j/config/AppConfig.java b/web3j/src/main/java/com/baeldung/web3j/config/AppConfig.java
new file mode 100644
index 0000000000..75ef948f7a
--- /dev/null
+++ b/web3j/src/main/java/com/baeldung/web3j/config/AppConfig.java
@@ -0,0 +1,68 @@
+package com.baeldung.web3j.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.resource.PathResourceResolver;
+import org.springframework.web.servlet.view.JstlView;
+import org.springframework.web.servlet.view.UrlBasedViewResolver;
+
+import java.util.concurrent.Executor;
+
+@Configuration
+@EnableWebMvc
+@EnableAsync
+@ComponentScan("com.baeldung.web3j")
+public class AppConfig implements WebMvcConfigurer {
+
+ public void addViewControllers(ViewControllerRegistry registry) {
+ registry.addViewController("/").setViewName("index");
+ }
+
+ /**
+ * Static resource locations including themes
+ */
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ registry.addResourceHandler("/resources/**/*")
+ .addResourceLocations("/", "/resources/")
+ .setCachePeriod(3600)
+ .resourceChain(true)
+ .addResolver(new PathResourceResolver());
+ }
+
+ /**
+ * View resolver for JSP
+ */
+ @Bean
+ public UrlBasedViewResolver viewResolver() {
+ UrlBasedViewResolver resolver = new UrlBasedViewResolver();
+ resolver.setPrefix("/WEB-INF/jsp/");
+ resolver.setSuffix(".jsp");
+ resolver.setViewClass(JstlView.class);
+ return resolver;
+ }
+
+ /**
+ * Configuration for async thread bean
+ *
+ * More: https://docs.spring.io/autorepo/docs/spring-framework/5.0.3.RELEASE/javadoc-api/org/springframework/scheduling/SchedulingTaskExecutor.html
+ */
+ @Bean
+ public Executor asyncExecutor() {
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ executor.setCorePoolSize(2);
+ executor.setMaxPoolSize(2);
+ executor.setQueueCapacity(500);
+ executor.setThreadNamePrefix("CsvThread");
+ executor.initialize();
+ return executor;
+ }
+
+}
\ No newline at end of file
diff --git a/web3j/src/main/java/com/baeldung/web3j/config/WebAppInitializer.java b/web3j/src/main/java/com/baeldung/web3j/config/WebAppInitializer.java
new file mode 100644
index 0000000000..8a9a8cf8c1
--- /dev/null
+++ b/web3j/src/main/java/com/baeldung/web3j/config/WebAppInitializer.java
@@ -0,0 +1,28 @@
+package com.baeldung.web3j.config;
+
+import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
+
+public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
+
+ //AbstractDispatcherServletInitializer override DEFAULT_SERVLET_NAME
+ @Override
+ protected String getServletName() {
+ return "dispatcher";
+ }
+
+ @Override
+ protected Class>[] getRootConfigClasses() {
+ return new Class[]{};
+ }
+
+ @Override
+ protected Class>[] getServletConfigClasses() {
+ return new Class[]{AppConfig.class};
+ }
+
+ @Override
+ protected String[] getServletMappings() {
+ return new String[]{"/"};
+ }
+
+}
\ No newline at end of file
diff --git a/web3j/src/main/java/com/baeldung/web3j/constants/Constants.java b/web3j/src/main/java/com/baeldung/web3j/constants/Constants.java
new file mode 100644
index 0000000000..005e4263cd
--- /dev/null
+++ b/web3j/src/main/java/com/baeldung/web3j/constants/Constants.java
@@ -0,0 +1,18 @@
+package com.baeldung.web3j.constants;
+
+public class Constants {
+
+ public static final String API_BLOCK = "/api/block";
+ public static final String API_ACCOUNTS = "/api/accounts";
+ public static final String API_TRANSACTIONS = "/api/transactions";
+ public static final String API_BALANCE = "/api/balance";
+
+ public static final String GENERIC_EXCEPTION = "Exception encountered!";
+ public static final String PLEASE_SUPPLY_REAL_DATA = "Please Supply Real Data!";
+
+ public static final String DEFAULT_ADDRESS = "0x281055afc982d96fab65b3a49cac8b878184cb16";
+ public static final String DEFAULT_CONTRACT_ADDRESS = "00000000000000000000";
+
+
+
+}
diff --git a/web3j/src/main/java/com/baeldung/web3j/contracts/Example.java b/web3j/src/main/java/com/baeldung/web3j/contracts/Example.java
new file mode 100644
index 0000000000..6909ca3e0c
--- /dev/null
+++ b/web3j/src/main/java/com/baeldung/web3j/contracts/Example.java
@@ -0,0 +1,74 @@
+package com.baeldung.web3j.contracts;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import org.web3j.abi.TypeReference;
+import org.web3j.abi.datatypes.Function;
+import org.web3j.abi.datatypes.Type;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.RemoteCall;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.tx.Contract;
+import org.web3j.tx.TransactionManager;
+
+/**
+ *
Auto generated code.
+ *
Do not modify!
+ *
Please use the web3j command line tools,
+ * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the
+ * codegen module to update.
+ *
+ *
Generated with web3j version 3.3.1.
+ */
+public class Example extends Contract {
+ private static final String BINARY = "0x60606040523415600e57600080fd5b60848061001c6000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063b818dacd146044575b600080fd5b3415604e57600080fd5b60546056565b005b5600a165627a7a72305820bebcbbdf06550591bc772dfcb0eadc842f95953869feb7a9528bac91487d95240029";
+
+ protected static final HashMap _addresses;
+
+ static {
+ _addresses = new HashMap<>();
+ }
+
+ protected Example(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
+ super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
+ }
+
+ protected Example(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
+ super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
+ }
+
+ public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
+ return deployRemoteCall(Example.class, web3j, credentials, gasPrice, gasLimit, BINARY, "");
+ }
+
+ public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
+ return deployRemoteCall(Example.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "");
+ }
+
+ public RemoteCall ExampleFunction() {
+ final Function function = new Function(
+ "ExampleFunction",
+ Arrays.asList(),
+ Collections.>emptyList());
+ return executeRemoteCallTransaction(function);
+ }
+
+ public static Example load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
+ return new Example(contractAddress, web3j, credentials, gasPrice, gasLimit);
+ }
+
+ public static Example load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
+ return new Example(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
+ }
+
+ protected String getStaticDeployedAddress(String networkId) {
+ return _addresses.get(networkId);
+ }
+
+ public static String getPreviouslyDeployedAddress(String networkId) {
+ return _addresses.get(networkId);
+ }
+}
diff --git a/web3j/src/main/java/com/baeldung/web3j/controllers/EthereumRestController.java b/web3j/src/main/java/com/baeldung/web3j/controllers/EthereumRestController.java
new file mode 100644
index 0000000000..e05517bc79
--- /dev/null
+++ b/web3j/src/main/java/com/baeldung/web3j/controllers/EthereumRestController.java
@@ -0,0 +1,103 @@
+package com.baeldung.web3j.controllers;
+
+import com.baeldung.web3j.constants.Constants;
+import com.baeldung.web3j.helpers.TimeHelper;
+import com.baeldung.web3j.services.Web3Service;
+import com.baeldung.web3j.transfers.ResponseTransfer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+import org.web3j.protocol.core.methods.response.EthAccounts;
+import org.web3j.protocol.core.methods.response.EthBlockNumber;
+import org.web3j.protocol.core.methods.response.EthGetBalance;
+import org.web3j.protocol.core.methods.response.EthGetTransactionCount;
+
+import java.time.Instant;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Future;
+
+import static com.baeldung.web3j.constants.Constants.GENERIC_EXCEPTION;
+
+@RestController
+public class EthereumRestController {
+
+ @Autowired
+ Web3Service web3Service;
+
+ @RequestMapping(value = Constants.API_BLOCK, method = RequestMethod.GET)
+ public Future getBlock() {
+ ResponseTransfer responseTransfer = new ResponseTransfer();
+ Instant start = TimeHelper.start();
+
+ return CompletableFuture.supplyAsync(() -> {
+ try {
+ CompletableFuture result = web3Service.getBlockNumber();
+ responseTransfer.setMessage(result.get().toString());
+ } catch (Exception e) {
+ responseTransfer.setMessage(GENERIC_EXCEPTION);
+ }
+ return responseTransfer;
+ }).thenApplyAsync(result -> {
+ result.setPerformance(TimeHelper.stop(start));
+ return result;
+ });
+ }
+
+ @RequestMapping(value = Constants.API_ACCOUNTS, method = RequestMethod.GET)
+ public Future getAccounts() {
+ ResponseTransfer responseTransfer = new ResponseTransfer();
+ Instant start = TimeHelper.start();
+
+ return CompletableFuture.supplyAsync(() -> {
+ try {
+ CompletableFuture result = web3Service.getEthAccounts();
+ responseTransfer.setMessage(result.get().toString());
+ } catch (Exception e) {
+ responseTransfer.setMessage(GENERIC_EXCEPTION);
+ }
+ return responseTransfer;
+
+ }).thenApplyAsync(result -> {
+ result.setPerformance(TimeHelper.stop(start));
+ return result;
+ });
+ }
+
+ @RequestMapping(value = Constants.API_TRANSACTIONS, method = RequestMethod.GET)
+ public Future getTransactions() {
+ ResponseTransfer responseTransfer = new ResponseTransfer();
+ Instant start = TimeHelper.start();
+ return CompletableFuture.supplyAsync(() -> {
+ try {
+ CompletableFuture result = web3Service.getTransactionCount();
+ responseTransfer.setMessage(result.get().toString());
+ } catch (Exception e) {
+ responseTransfer.setMessage(GENERIC_EXCEPTION);
+ }
+ return responseTransfer;
+ }).thenApplyAsync(result -> {
+ result.setPerformance(TimeHelper.stop(start));
+ return result;
+ });
+ }
+
+ @RequestMapping(value = Constants.API_BALANCE, method = RequestMethod.GET)
+ public Future getBalance() {
+ ResponseTransfer responseTransfer = new ResponseTransfer();
+ Instant start = TimeHelper.start();
+ return CompletableFuture.supplyAsync(() -> {
+ try {
+ CompletableFuture result = web3Service.getEthBalance();
+ responseTransfer.setMessage(result.get().toString());
+ } catch (Exception e) {
+ responseTransfer.setMessage(GENERIC_EXCEPTION);
+ }
+ return responseTransfer;
+ }).thenApplyAsync(result -> {
+ result.setPerformance(TimeHelper.stop(start));
+ return result;
+ });
+ }
+
+}
\ No newline at end of file
diff --git a/web3j/src/main/java/com/baeldung/web3j/helpers/TimeHelper.java b/web3j/src/main/java/com/baeldung/web3j/helpers/TimeHelper.java
new file mode 100644
index 0000000000..360fe088ba
--- /dev/null
+++ b/web3j/src/main/java/com/baeldung/web3j/helpers/TimeHelper.java
@@ -0,0 +1,16 @@
+package com.baeldung.web3j.helpers;
+
+import java.time.Duration;
+import java.time.Instant;
+
+public class TimeHelper {
+
+ public static Instant start() {
+ return Instant.now();
+ }
+
+ public static Duration stop(Instant start) {
+ Instant end = Instant.now();
+ return Duration.between(start, end);
+ }
+}
diff --git a/web3j/src/main/java/com/baeldung/web3j/services/Web3Service.java b/web3j/src/main/java/com/baeldung/web3j/services/Web3Service.java
new file mode 100644
index 0000000000..790210d557
--- /dev/null
+++ b/web3j/src/main/java/com/baeldung/web3j/services/Web3Service.java
@@ -0,0 +1,156 @@
+package com.baeldung.web3j.services;
+
+import com.baeldung.web3j.contracts.Example;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.web3j.abi.FunctionEncoder;
+import org.web3j.abi.datatypes.Function;
+import org.web3j.crypto.Credentials;
+import org.web3j.crypto.WalletUtils;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.DefaultBlockParameter;
+import org.web3j.protocol.core.methods.request.Transaction;
+import org.web3j.protocol.core.methods.response.EthAccounts;
+import org.web3j.protocol.core.methods.response.EthBlockNumber;
+import org.web3j.protocol.core.methods.response.EthGetBalance;
+import org.web3j.protocol.core.methods.response.EthGetTransactionCount;
+import org.web3j.protocol.http.HttpService;
+import org.web3j.tx.Contract;
+import org.web3j.tx.ManagedTransaction;
+
+import java.io.File;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+import static com.baeldung.web3j.constants.Constants.DEFAULT_ADDRESS;
+import static com.baeldung.web3j.constants.Constants.GENERIC_EXCEPTION;
+import static com.baeldung.web3j.constants.Constants.PLEASE_SUPPLY_REAL_DATA;
+
+@Service
+public class Web3Service {
+
+ private Web3j web3j = Web3j.build(new HttpService());
+
+ //Create and Init the default Web3J connection
+ public void customInit(String provider) {
+ this.web3j = Web3j.build(new HttpService(provider));
+ }
+
+ //Convert to and from supplied contract ABI bytecode
+ public static String toBinary(String bytecode) {
+ return bytecode.replaceFirst("^0x", "");
+ }
+
+ public static String toByteCode(String binary) {
+ return "0x" + binary;
+ }
+
+ @Async
+ public CompletableFuture getBlockNumber() {
+ EthBlockNumber result = new EthBlockNumber();
+ try {
+ this.web3j.ethBlockNumber().sendAsync().thenApply(r -> r.getBlockNumber());
+ } catch (Exception ex) {
+ System.out.println(GENERIC_EXCEPTION);
+ }
+ return CompletableFuture.completedFuture(result);
+ }
+
+ @Async
+ public CompletableFuture getEthAccounts() {
+ EthAccounts result = new EthAccounts();
+ try {
+ this.web3j.ethAccounts().sendAsync().thenApply(r -> r.getAccounts());
+ } catch (Exception ex) {
+ System.out.println(GENERIC_EXCEPTION);
+ }
+ return CompletableFuture.completedFuture(result);
+ }
+
+ @Async
+ public CompletableFuture getTransactionCount() {
+ EthGetTransactionCount result = new EthGetTransactionCount();
+ try {
+ this.web3j.ethGetTransactionCount(DEFAULT_ADDRESS, DefaultBlockParameter.valueOf("latest")).sendAsync().thenApply(r -> r.getTransactionCount());
+ } catch (Exception ex) {
+ System.out.println(GENERIC_EXCEPTION);
+ }
+ return CompletableFuture.completedFuture(result);
+ }
+
+ @Async
+ public CompletableFuture getEthBalance() {
+ EthGetBalance result = new EthGetBalance();
+ try {
+ this.web3j.ethGetBalance(DEFAULT_ADDRESS, DefaultBlockParameter.valueOf("latest")).sendAsync().thenApply(r -> r.getBalance());
+ } catch (Exception ex) {
+ System.out.println(GENERIC_EXCEPTION);
+ }
+ return CompletableFuture.completedFuture(result);
+ }
+
+ @Async
+ public CompletableFuture fromScratchContractExample() {
+
+ String contractAddress = "";
+
+ try {
+ //Create a wallet
+ WalletUtils.generateNewWalletFile("PASSWORD", new File("/path/to/destination"), true);
+ //Load the credentials from it
+ Credentials credentials = WalletUtils.loadCredentials("PASSWORD", "/path/to/walletfile");
+
+ //Deploy contract to address specified by wallet
+ Example contract = Example.deploy(this.web3j,
+ credentials,
+ ManagedTransaction.GAS_PRICE,
+ Contract.GAS_LIMIT).send();
+
+ //Het the address
+ contractAddress = contract.getContractAddress();
+
+ } catch (Exception ex) {
+ System.out.println(PLEASE_SUPPLY_REAL_DATA);
+ return CompletableFuture.completedFuture(PLEASE_SUPPLY_REAL_DATA);
+ }
+ return CompletableFuture.completedFuture(contractAddress);
+ }
+
+ @Async
+ public CompletableFuture sendTx() {
+ String transactionHash = "";
+
+ try {
+ List inputParams = new ArrayList();
+ List outputParams = new ArrayList();
+ Function function = new Function("fuctionName", inputParams, outputParams);
+
+ String encodedFunction = FunctionEncoder.encode(function);
+
+ BigInteger nonce = BigInteger.valueOf(100);
+ BigInteger gasprice = BigInteger.valueOf(100);
+ BigInteger gaslimit = BigInteger.valueOf(100);
+
+ Transaction transaction = Transaction.createFunctionCallTransaction("FROM_ADDRESS", nonce, gasprice, gaslimit, "TO_ADDRESS", encodedFunction);
+
+ org.web3j.protocol.core.methods.response.EthSendTransaction transactionResponse = web3j.ethSendTransaction(transaction).sendAsync().get();
+ transactionHash = transactionResponse.getTransactionHash();
+
+ } catch (Exception ex) {
+ System.out.println(PLEASE_SUPPLY_REAL_DATA);
+ return CompletableFuture.completedFuture(PLEASE_SUPPLY_REAL_DATA);
+ }
+
+ return CompletableFuture.completedFuture(transactionHash);
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/web3j/src/main/java/com/baeldung/web3j/transfers/ResponseTransfer.java b/web3j/src/main/java/com/baeldung/web3j/transfers/ResponseTransfer.java
new file mode 100644
index 0000000000..9c5d1799ff
--- /dev/null
+++ b/web3j/src/main/java/com/baeldung/web3j/transfers/ResponseTransfer.java
@@ -0,0 +1,28 @@
+package com.baeldung.web3j.transfers;
+
+import java.time.Duration;
+
+public class ResponseTransfer {
+
+ public ResponseTransfer() {}
+
+ private Duration performance;
+ private String message;
+
+ public Duration getPerformance() {
+ return performance;
+ }
+
+ public void setPerformance(Duration performance) {
+ this.performance = performance;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/web3j/src/main/webapp/WEB-INF/.gitkeep b/web3j/src/main/webapp/WEB-INF/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/web3j/src/main/webapp/resources/.gitkeep b/web3j/src/main/webapp/resources/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/web3j/src/test/com/baeldung/web3j/controllers/EthereumRestControllerIntegrationTest.java b/web3j/src/test/com/baeldung/web3j/controllers/EthereumRestControllerIntegrationTest.java
new file mode 100644
index 0000000000..ee78ab17c2
--- /dev/null
+++ b/web3j/src/test/com/baeldung/web3j/controllers/EthereumRestControllerIntegrationTest.java
@@ -0,0 +1,78 @@
+package com.baeldung.web3j.controllers;
+
+
+import com.baeldung.web3j.config.AppConfig;
+import com.baeldung.web3j.constants.Constants;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {AppConfig.class})
+@WebAppConfiguration
+public class EthereumRestControllerIntegrationTest {
+
+ private MockMvc mockMvc;
+
+ private void constructAsyncTest(String endpoint) {
+ try {
+ MvcResult asyncResult = mockMvc
+ .perform(get(endpoint))
+ .andReturn();
+
+ mockMvc.perform(asyncDispatch(asyncResult))
+ .andDo(print())
+ .andExpect(status().isOk());
+
+ } catch (Exception e) {
+ System.out.println("Exception: " + e);
+ }
+ }
+
+ @Autowired
+ private WebApplicationContext wac;
+
+ @Before
+ public void preTest() throws Exception {
+ mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
+ }
+
+ @Test
+ public void accounts() {
+ constructAsyncTest(Constants.API_ACCOUNTS);
+ }
+
+ @Test
+ public void transactions() {
+ constructAsyncTest(Constants.API_TRANSACTIONS);
+ }
+
+ @Test
+ public void block() {
+ constructAsyncTest(Constants.API_BLOCK);
+ }
+
+ @Test
+ public void balance() {
+ constructAsyncTest(Constants.API_BALANCE);
+ }
+
+ @After
+ public void postTest() {
+ mockMvc = null;
+ }
+}
\ No newline at end of file
diff --git a/web3j/src/test/com/baeldung/web3j/controllers/EthereumRestControllerUnitTest.java b/web3j/src/test/com/baeldung/web3j/controllers/EthereumRestControllerUnitTest.java
new file mode 100644
index 0000000000..4ceed870f8
--- /dev/null
+++ b/web3j/src/test/com/baeldung/web3j/controllers/EthereumRestControllerUnitTest.java
@@ -0,0 +1,76 @@
+package com.baeldung.web3j.controllers;
+
+import com.baeldung.web3j.constants.Constants;
+import com.baeldung.web3j.services.Web3Service;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+public class EthereumRestControllerUnitTest {
+
+ private MockMvc mockMvc;
+
+ private void constructAsyncTest(String endpoint) {
+ try {
+ MvcResult asyncResult = mockMvc
+ .perform(get(endpoint))
+ .andReturn();
+
+ mockMvc.perform(asyncDispatch(asyncResult))
+ .andDo(print())
+ .andExpect(status().isOk());
+
+ } catch (Exception e) {
+ System.out.println("Exception: " + e);
+ }
+ }
+
+ @Mock
+ private Web3Service web3Service;
+
+ @InjectMocks
+ private EthereumRestController ethereumRestController;
+
+ @Before
+ public void preTest() {
+ MockitoAnnotations.initMocks(this);
+ mockMvc = MockMvcBuilders.standaloneSetup(ethereumRestController).build();
+ }
+
+ @Test
+ public void accounts() {
+ constructAsyncTest(Constants.API_ACCOUNTS);
+ }
+
+ @Test
+ public void transactions() {
+ constructAsyncTest(Constants.API_TRANSACTIONS);
+ }
+
+ @Test
+ public void block() {
+ constructAsyncTest(Constants.API_BLOCK);
+ }
+
+ @Test
+ public void balance() {
+ constructAsyncTest(Constants.API_BALANCE);
+ }
+
+ @After
+ public void postTest() {
+ mockMvc = null;
+ }
+
+}
diff --git a/web3j/src/test/com/baeldung/web3j/services/EthereumContractUnitTest.java b/web3j/src/test/com/baeldung/web3j/services/EthereumContractUnitTest.java
new file mode 100644
index 0000000000..5c74e1c7ce
--- /dev/null
+++ b/web3j/src/test/com/baeldung/web3j/services/EthereumContractUnitTest.java
@@ -0,0 +1,37 @@
+package com.baeldung.web3j.services;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.concurrent.CompletableFuture;
+
+import static com.baeldung.web3j.constants.Constants.PLEASE_SUPPLY_REAL_DATA;
+
+public class EthereumContractUnitTest {
+
+ private Web3Service web3Service;
+
+ @Before
+ public void setup() {
+ web3Service = new Web3Service();
+ }
+
+ @Test
+ public void testContract() {
+ CompletableFuture result = web3Service.fromScratchContractExample();
+ assert (result instanceof CompletableFuture);
+ }
+
+ @Test
+ public void sendTx() {
+ CompletableFuture result = web3Service.sendTx();
+ assert (result instanceof CompletableFuture);
+ }
+
+ @After
+ public void cleanup() {
+ }
+}