From 37b783ad89c11f00495c17a59e0b4585b3aa351e Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Thu, 2 Mar 2017 00:13:44 -0500 Subject: [PATCH] Retrieving the LICENSE file and expanding the README.md --- graphenej/LICENSE => LICENSE | 0 README.md | 41 ++++++++++++++++++++++++++++++++++++ graphenej/README.md | 2 -- 3 files changed, 41 insertions(+), 2 deletions(-) rename graphenej/LICENSE => LICENSE (100%) create mode 100644 README.md delete mode 100644 graphenej/README.md diff --git a/graphenej/LICENSE b/LICENSE similarity index 100% rename from graphenej/LICENSE rename to LICENSE diff --git a/README.md b/README.md new file mode 100644 index 0000000..4912c7f --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# graphenej +A Java library for mobile app Developers; Graphene/Bitshares blockchain. + +#Sample use +##Very simple funds transfer + +This is a simple transfer operation of 1 BTS from account **bilthon-15** to **bilthon-5** +```java +// Creating a transfer operation +TransferOperation transferOperation = new TransferOperationBuilder() + .setTransferAmount(new AssetAmount(UnsignedLong.valueOf(100000), new Asset("1.3.0"))) + .setSource(new UserAccount("1.2.143563")) // bilthon-15 + .setDestination(new UserAccount("1.2.139313")) // bilthon-5 + .setFee(new AssetAmount(UnsignedLong.valueOf(264174), new Asset("1.3.0"))) + .build(); + +// Adding operations to the operation list +ArrayList operationList = new ArrayList<>(); +operationList.add(transferOperation); + +// Creating a transaction instance +Transaction transaction = new Transaction(sourcePrivateKey, null, operationList); +``` + +From here on, it is just a matter of creating a websocket connection and using a custom handler called +```TransactionBroadcastSequence``` in order to broadcast it to the witness node. + +```java +// Setting up a secure websocket connection. +SSLContext context = null; +context = NaiveSSLContext.getInstance("TLS"); +WebSocketFactory factory = new WebSocketFactory(); +factory.setSSLContext(context); + +WebSocket mWebSocket = factory.createSocket(FULL_NODE_URL); + +mWebSocket.addListener(new TransactionBroadcastSequence(transaction, new Asset("1.3.0"), listener)); +mWebSocket.connect(); +``` + +The provided ```listener``` is an instance of the class ```WitnessResponseListener```. \ No newline at end of file diff --git a/graphenej/README.md b/graphenej/README.md deleted file mode 100644 index efe6d20..0000000 --- a/graphenej/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# graphenej -A Java library for mobile app Developers; Graphene/Bitshares blockchain.