Created
September 28, 2018 09:29
-
-
Save adyliu/492503b94d0306371298f24e15481da4 to your computer and use it in GitHub Desktop.
sign transaction offline for eos transfer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eos.sample; | |
import java.time.LocalDateTime; | |
import java.util.Arrays; | |
import java.util.List; | |
import org.apache.log4j.BasicConfigurator; | |
import io.jafka.jeos.EosApi; | |
import io.jafka.jeos.EosApiFactory; | |
import io.jafka.jeos.LocalApi; | |
import io.jafka.jeos.core.common.SignArg; | |
import io.jafka.jeos.core.common.transaction.PackedTransaction; | |
import io.jafka.jeos.core.common.transaction.SignedPackedTransaction; | |
import io.jafka.jeos.core.request.chain.transaction.PushTransactionRequest; | |
import io.jafka.jeos.core.response.chain.transaction.PushedTransaction; | |
/** | |
* | |
* @author adyliu ([email protected]) | |
* @since Sep 28, 2018 | |
*/ | |
public class OfflineEOSTransfer { | |
public static void main(String[] args) throws Exception{ | |
// --- get the current state of blockchain | |
EosApi eosApi = EosApiFactory.create("http://jungle.cryptolions.io:18888"); | |
SignArg arg = eosApi.getSignArg(120); | |
System.out.println(eosApi.getObjectMapper().writeValueAsString(arg)); | |
// --- sign the transation of token tansfer | |
String privateKey = "5JTKZ------";//replace the real private key | |
String from = "shijiebangmm"; | |
String to = "womenshi1111"; | |
String quantity = "0.2345 EOS"; | |
String memo = "sent by eos sdk (https://github.com/adyliu/jeos"; | |
LocalApi localApi = EosApiFactory.createLocalApi(); | |
PushTransactionRequest req = localApi.transfer(arg, privateKey, from, to, quantity, memo); | |
System.out.println(localApi.getObjectMapper().writeValueAsString(req)); | |
// --- push the signed-transaction to the blockchain | |
PushedTransaction pts = eosApi.pushTransaction(req); | |
System.out.println(localApi.getObjectMapper().writeValueAsString(pts)); | |
} | |
} |
not getting any data in link: https://eospark.com/Jungle/tx/9cb5b98d2cda1bd9b0b226431acb2b72eaec7c82bc26f818aced022d82b0cd6c
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
got the result