espritblock / eos4j Goto Github PK
View Code? Open in Web Editor NEWeos4j create by espritblock
Home Page: http://eblock.io
License: GNU General Public License v3.0
eos4j create by espritblock
Home Page: http://eblock.io
License: GNU General Public License v3.0
all the describe of error is "io.eblock.eos4j.api.exception.ApiException: Internal Service Error" ,how to get the error detail
exp:
try {
Transaction t1 = rpc.transfer("5Ka2MNvrtWfNDueCvt4yBMSoKNMNdnL8bcdv94PkgJhpxvTr3Uo","eosio.token", "eosio.token","lishi12", "12.2821 EOS", "");
}catch(Exception ex) {
ex.printStackTrace();
//"io.eblock.eos4j.api.exception.ApiException: Internal Service Error
}
public class Generator {
private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
private static Retrofit.Builder builder = new Retrofit.Builder()
.addConverterFactory(JacksonConverterFactory.create());
private static Retrofit retrofit;
public static <S> S createService(Class<S> serviceClass, String baseUrl) {
return createService(serviceClass, baseUrl, false);
}
public static <S> S createService(Class<S> serviceClass, String baseUrl, boolean debug) {
if (debug) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(Level.BODY);
httpClient.addInterceptor(logging);
}
builder.baseUrl(baseUrl);
OkHttpClient okHttpClient = httpClient.build();
builder.client(okHttpClient);
builder.addConverterFactory(JacksonConverterFactory.create()); //该行代码会造成内存溢出
retrofit = builder.build();
return retrofit.create(serviceClass);
}
public static <T> T executeSync(Call<T> call) throws Exception {
Response<T> response = call.execute();
if (response.isSuccessful()) {
return response.body();
} else {
try {
ApiError apiError = getApiError(response);
throw new ApiException(apiError);
} catch (ApiException e1) {
throw e1;
} catch (Exception e) {
e.printStackTrace();
ApiError apiError = new ApiError();
io.eblock.eos4j.api.exception.Error error = new io.eblock.eos4j.api.exception.Error();
error.setWhat("unknow exception");
apiError.setError(error);
throw new ApiException(apiError);
}
}
}
private static ApiError getApiError(Response<?> response) throws IOException, ApiException {
return (ApiError) retrofit.responseBodyConverter(ApiError.class, new Annotation[0]).convert(response.errorBody());
}
}
builder是一个static变量,每次调用createService方法的时候调用builder.addConverterFactory(JacksonConverterFactory.create()),该行代码会往builder对象的converterFactories(ArrayList)变量插入一个JacksonConverterFactory.create()对象,如果调用次数过多,就会出现内存溢出;其实,在该类初始化的时候已经执行了
private static Retrofit.Builder builder = new Retrofit.Builder()
.addConverterFactory(JacksonConverterFactory.create());
,后面的createService方法就没必要再调用builder.addConverterFactory(JacksonConverterFactory.create());了
就比如我自己想主账号想给小号抵押cpu,不想租,,还有就是赎回cpu的方法
Map<String, Object> dataMap = new LinkedHashMap<>();
dataMap.put("payer", "testaccount1");
dataMap.put("receiver", "testaccount1");
dataMap.put("quant", new DataParam("2.0000 EOS", DataType.asset, Action.transfer).getValue());
TxAction action = new TxAction("testaccount1", “eosio”, "buyram", dataMap);
.....
// sgin
String sign = Ecc.signTransaction(pk, new TxSign(info.getChainId(), tx));//I am sure the pk is the privakey //of testaccount1,and just need the auth of active
I want to call this system method to buy ram with eos ,Will report such a mistake:
but does not have signatures for it under a provided delay of 0 ms, provided permissions []
I do not know why .
if use the method of buyrambytes and input right params can run success.
转账方法的 asset 序列化时,把 amount 处理成整数时,没有考虑小数点后位数超过 4 的情况,导致如果传的金额是 '100.12345 EOS' 时,转成的整数变成 '10012345', 而不是 '1001234'。
问题代码在这里
一直提示 Provided keys, permissions, and delays do not satisfy declared authorizations
没法用maven导入吗
同样的代码,在pc使用java直接进行转账是成功的,但是放在手机上跑就失败了
私链测试账户有币
root@eos-120:# cleos get currency balance eosio.token eostest1# cleos get currency balance eosio.token eostest2
100.0000 EOS
root@eos-120:
1.0000 EOS
转账报错
94字符以下可正常transfer
Project gradle
allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven {
url "https://jitpack.io"
}
}
}
app gradle
implementation 'com.github.espritblock:eos4j:master-SNAPSHOT'
错误信息:
Failed to resolve: com.github.espritblock:eos4j:master-SNAPSHOT
我在eos上用acchello发布了一个名为hello智能合约,有个函数hi(string account_name),怎么用这个sdk去调用hi函数呢?
你好,
新手,问题可能很初级,请多包涵!
如题,log如下:
******************* Ecc Start *******************
============= 通过种子生成私钥 ===============
private key :5JYgcuybUYKAuqrx9QZFUsDWiMh31DH1soFwKcyWuoq9oD5Fb22
============= 通过私钥生成公钥 ===============
public key :EOS7Wz4yF2HMQKuDPEVJEgw91D6Y1ycqUPHpWrpmdPWCDQuGPSFef
============= 自定义数据签名 ===============
sign :SIG_K1_KfKhJFzFVffT5zmWs59SZG8vTkgC6MrGYJuPQTWLPwjXU2MHKu24mXg2DhfLQR7ovgEHg57HMAc61aq36gYv1mq342R56T
============= 转账数据序列化 ===============
seriz data :00f2d4142123e95d0000c85353840ccdb486010000000000045359530000000019e6b58be8af95313233616263646f2e2f2c2e2f214023232425
transfer eq eosjs seriz true
============= 创建账户数据序列化 ===============
seriz data :0000000000ea30550002a2f164772b5601000000010003ee4221c9c3f4f62646e3c758dbb8abaae506a559f67148a76968fa6b0f0868140100000001000000010003ba8de2f029cae85e7ca5c9f591bb17b86d750c5116cec30d94100e16e446d41501000000
account eq eosjs seriz true
******************* Ecc End *******************
******************* Rpc Start *******************
******************* Rpc:http://localhost:8888 *******************
============= 转账 ===============
{"compression":"none","transaction":{"expiration":"2018-07-24T03:11:50","ref_block_num":147147,"ref_block_prefix":2402983549,"net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"espritblocke","name":"transfer","authorization":[{"actor":"inita","permission":"active"}],"data":"000000000093dd74000000008093dd74c5df010000000000044d53500000000000"}],"transaction_extensions":[]},"signatures":["SIG_K1_KfewGFL57uoNArqgzabFJ5FVP3nUrMeTvLarjP8PvHwVjqoKH3zj2vfMzv7dwSZwMsRAZYb82TCju3fDUnDqBNccvjBRgn"]}
io.eblock.eos4j.api.exception.ApiException: Internal Service Error
at io.eblock.eos4j.api.utils.Generator.executeSync(Generator.java:38)
at io.eblock.eos4j.Rpc.pushTransaction(Rpc.java:100)
at io.eblock.eos4j.Rpc.transfer(Rpc.java:155)
at io.eblock.eos4j.Test.main(Test.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
============= 创建账户并且抵押 ===============
{"compression":"none","transaction":{"expiration":"2018-07-24T03:11:51","ref_block_num":147148,"ref_block_prefix":934036916,"net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"newaccount","authorization":[{"actor":"eosio","permission":"active"}],"data":"0000000000ea305570ce39070084104201000000010003ee4221c9c3f4f62646e3c758dbb8abaae506a559f67148a76968fa6b0f0868140100000001000000010003ee4221c9c3f4f62646e3c758dbb8abaae506a559f67148a76968fa6b0f08681401000000"},{"account":"eosio","name":"buyrambytes","authorization":[{"actor":"eosio","permission":"active"}],"data":"0000000000ea305570ce39070084104200200000"},{"account":"eosio","name":"delegatebw","authorization":[{"actor":"eosio","permission":"active"}],"data":"0000000000ea305570ce390700841042640000000000000004535953000000006400000000000000045359530000000000"}],"transaction_extensions":[]},"signatures":["SIG_K1_KaRX4vMPSKTEjz3tw3wVJ8mqAj6wxKfmuE2gEPnkrgnUPuMiFnUTBNDXgpyZXGbu95ECvkeBC8om7Wf3ZBHaYHdzRs7dnn"]}
io.eblock.eos4j.api.exception.ApiException: Internal Service Error
at io.eblock.eos4j.api.utils.Generator.executeSync(Generator.java:38)
at io.eblock.eos4j.Rpc.pushTransaction(Rpc.java:100)
at io.eblock.eos4j.Rpc.createAccount(Rpc.java:304)
at io.eblock.eos4j.Test.main(Test.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
============= 创建账户不抵押 ===============
{"compression":"none","transaction":{"expiration":"2018-07-24T03:11:51","ref_block_num":147149,"ref_block_prefix":195447596,"net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"newaccount","authorization":[{"actor":"eosio","permission":"active"}],"data":"0000000000ea3055008218a40070ce3901000000010003ee4221c9c3f4f62646e3c758dbb8abaae506a559f67148a76968fa6b0f0868140100000001000000010003ee4221c9c3f4f62646e3c758dbb8abaae506a559f67148a76968fa6b0f08681401000000"},{"account":"eosio","name":"buyrambytes","authorization":[{"actor":"eosio","permission":"active"}],"data":"0000000000ea3055008218a40070ce3900200000"}],"transaction_extensions":[]},"signatures":["SIG_K1_Kb4dV4EdavrzVdNZjHpWv56xJMW5f8LWLs19pY4k9V9je2yJAfGo6mdvpzoker6L9BWcKrfNPompemnktjUDRfjbDn3T6u"]}
io.eblock.eos4j.api.exception.ApiException: Internal Service Error
at io.eblock.eos4j.api.utils.Generator.executeSync(Generator.java:38)
at io.eblock.eos4j.Rpc.pushTransaction(Rpc.java:100)
at io.eblock.eos4j.Rpc.createAccount(Rpc.java:218)
at io.eblock.eos4j.Test.main(Test.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
******************* Rpc End *******************
[WARNING] thread Thread[OkHttp ConnectionPool,5,io.eblock.eos4j.Test] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[OkHttp ConnectionPool,5,io.eblock.eos4j.Test] will linger despite being asked to die via interruption
[WARNING] thread Thread[Okio Watchdog,5,io.eblock.eos4j.Test] will linger despite being asked to die via interruption
[WARNING] NOTE: 2 thread(s) did not finish despite being asked to via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=io.eblock.eos4j.Test,maxpri=10]
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.destroy(ThreadGroup.java:778)
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:321)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
=====》
io.eblock.eos4j.api.exception.ApiException: Internal Service Error
这个一般是什么导致的?我的nodeos是使用官网推荐的方式启动,RPC通讯是没有问题的:
$ curl http://localhost:8888/v1/chain/get_info
{"server_version":"75635168","chain_id":"cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f","head_block_num":155719,"last_irreversible_block_num":155718,"last_irreversible_block_id":"00026046a9ba97a0995d7463c362855130b47fa8313569033ce28f22afaef1f7","head_block_id":"000260479ccdbf913f1e1480e08738aa1bf7c4bb64cd8bedf976cb1ba1101cd9","head_block_time":"2018-07-24T04:22:25.000","head_block_producer":"eosio","virtual_block_cpu_limit":200000000,"virtual_block_net_limit":1048576000,"block_cpu_limit":199900,"block_net_limit":1048576}
有线上RPC发币的功能吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.