diff --git a/sample-project-gradle-master/README.md b/sample-project-gradle-master/README.md index f146ae7467fa4cedbf3509f4fd68c6ad063bbe5e..f398c090713509265c76a0c2815250ce17dd1e84 100644 --- a/sample-project-gradle-master/README.md +++ b/sample-project-gradle-master/README.md @@ -1,7 +1,9 @@ #MARINOS ILIADIS + ##Eclipse Gradle project ## How to import the project into Eclipse + Open Eclipse -> Go to File -> Open Project From File System -> Show other specialised import wizard-> Gradle -> Existing Gradle -> sample-project-gradle-master Import this project to Eclipse (I use Eclipse Oxygen 3A) as an existing grandle project. Our eclipse project uses the web3j library. Java library to interact with Ethereum blockchain and solidity smart contracts @@ -30,10 +32,20 @@ https://docs.web3j.io/command_line.html OR +Using the MyEtherWallet website to create an Ethereum wallet file +https://www.myetherwallet.com/ + +### Manage account + By using MetaMask Google Chrome Extension check how it works here: https://metamask.io/ +OR +By visiting Etherscan's website and add the addres to th search bar +https://etherscan.io/ + + ### Request some ether Import the wallet file into the MetaMask account. @@ -58,6 +70,7 @@ https://infura.io/register.html In this prototype java dapp we deploy our contract on the Ropsten Test Network ### Solidity compiler and Java wrappers + A) Compiling Solidity source code 1) npm install -g solc 2) solc or solcjs <contract>.sol --bin --abi --optimize -o <output-dir>/ @@ -73,7 +86,6 @@ Solidity smart contract wrappers Link: https://docs.web3j.io/smart_contracts.html#smart-contract-wrappers - ### Viewing logs on blockchain Logback configuration is provided in the project dependencies giving the opportunity to logging of protocol @@ -83,7 +95,7 @@ To enable change the following line in the logback configuration: ```xml <logger name="org.web3j.protocol" level="DEBUG"/> ``` -### Extra Dependencties (check build.grandle) +### Extra Dependencies (check build.grandle) Assert java 3.10.0 Javatuples 1.2 diff --git a/sample-project-gradle-master/src/main/java/org/web3j/sample/Application.java b/sample-project-gradle-master/src/main/java/org/web3j/sample/Application.java index 3f689b7849fb9c2ea3463c82263ba0bb4ac8551a..65e44e64e029fb7719342e313afb6236a8b12ae8 100644 --- a/sample-project-gradle-master/src/main/java/org/web3j/sample/Application.java +++ b/sample-project-gradle-master/src/main/java/org/web3j/sample/Application.java @@ -49,14 +49,14 @@ public class Application { Web3j web3j = Web3j.build(new HttpService("https://ropsten.infura.io/fIJ2SJzY4NaKGKA9Ryxp")); //Need to add you Infura token. Sent to you by email when you register. Use the one for Ropsten. log.info("Connected to Ethereum client version: " + web3j.web3ClientVersion().send().getWeb3ClientVersion()); - //Load your Credentials and Ethereum wallet + //Load your Credentials and Ethereum wallet file Credentials credentials = WalletUtils.loadCredentials( "1234", //Need to add the password you have set for this wallet file "C:\\Users\\Marinos\\Desktop\\test_gitlab\\db-blockchain-privacy\\sample-project-gradle-master\\wallet\\UTC--2018-06-16T11-26-34.298000000Z--fc87f1c9459a4e15731d004ebd923821f89aa007.json"); //Need to add the path of your generated Ethereum wallet file (.json). log.info("Credentials loaded"); //Check the folder wallet inside the project folder to find an existing wallet file. - //Send 1 wei from your address to another address + //Send 1 Wei from your address to another address log.info("Sending 1 Wei (" + Convert.fromWei("1", Convert.Unit.ETHER).toPlainString() + " Ether)"); TransactionReceipt transferReceipt = Transfer.sendFunds( @@ -98,14 +98,17 @@ public class Application { * Print results */ - //Deploy our smart contract - db.sol + //Deploy our smart contract - Acladv.sol log.info("Deploying smart contract - ACL-BaseData"); Acladv contract = Acladv.deploy( web3j, credentials, - ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT).send(); - + ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT).send(); //Get address of the deployed smart contract String contractAddress = contract.getContractAddress(); + log.info("Smart Contract deployed to address: " + contractAddress); + //Check the contract on Etherscan website + log.info("View contract at https://ropsten.etherscan.io/address/" + contractAddress); + // String adro = contract.getDeployedAddress("1"); // String adrt = contract.getDeployedAddress("2"); // String adrtr = contract.getDeployedAddress("3"); @@ -114,8 +117,8 @@ public class Application { // log.info("Smart Contract deployed to address: " + adrt); // log.info("Smart Contract deployed to address: " + adrtr); // log.info("Smart Contract deployed to address: " + adrf); - log.info("Smart Contract deployed to address: " + contractAddress); - //log.info("View contract at https://ropsten.etherscan.io/address/" + contractAddress); +// log.info("Smart Contract deployed to address: " + contractAddress); +// log.info("View contract at https://ropsten.etherscan.io/address/" + contractAddress); //Add user to the access control list TransactionReceipt userone = contract.addUser("0xFC87F1c9459A4e15731d004EbD923821f89AA007").send();