conflux-chain / java-conflux-sdk Goto Github PK
View Code? Open in Web Editor NEWConflux Java SDK
Conflux Java SDK
conflux.web3j.RpcException: RPC error: code = -32015, message = Estimation isn't accurate: transaction is reverted. Innermost error is at CFXTEST:TYPE.CONTRACT:ACDDH6V0XPXCXYAZB6ECU9D971PNA0NCFYWHW3B956: Vm reverted. ., data = "0x434658544553543a545950452e434f4e54524143543a4143444448365630585058435859415a42364543553944393731504e41304e43465957485733423935363a20566d2072657665727465642e20"
at conflux.web3j.Request.sendAndGet(Request.java:69)
at conflux.web3j.Request.sendAndGet(Request.java:62)
at conflux.web3j.Request.sendAndGet(Request.java:58)
at conflux.web3j.Account$Option.applyDefault(Account.java:288)
at conflux.web3j.Account$Option.buildTx(Account.java:300)
at conflux.web3j.Account$Option.access$000(Account.java:178)
at conflux.web3j.Account.buildRawTransaction(Account.java:127)
at conflux.web3j.Account.callWithData(Account.java:174)
at conflux.web3j.Account.call(Account.java:166)
at com.codingapi.confluxcontract.ContractTest.update(ContractTest.java:60)
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.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
code:
String privateKey = "0x...";
// int netId = 1;
Address contractAddress = new Address("cfxtest:acddh6v0xpxcxyazb6ecu9d971pna0ncfywhw3b956");
Address userAddress = new Address("cfxtest:aat6twwp0z9dpntk0exgu43f5g6rhrxa2ap8k64z4j");
// BigInteger amount = new BigInteger("1");
Cfx cfx = Cfx.create("https://test.confluxrpc.com", 3, 1000);
// ContractCall contract = new ContractCall(cfx, contractAddress);
// create account, then call contract's method
Account account = Account.create(cfx, privateKey);
Account.Option opt = new Account.Option();
// build transaction option info: nonce, gas, gasPrice and etc
opt.withChainId(userAddress.getNetworkId());
// opt.withGasLimit(1000000000000L);
// opt.withGasPrice(new BigInteger("10000000"));
// opt.withValue(new BigInteger("3"));
// opt.withValue(new BigInteger());
String txHash = account.call(
opt,
contractAddress,
"safeTransferFrom",
account.getAddress().getABIAddress(),
userAddress.getABIAddress(),
new Uint256(1),
new Uint256(1),
Bytes32.DEFAULT
);
System.out.println("tx hash: " + txHash);
Please help enhance the Account
class with following utilities:
deploy
with file (e.g. truffle compiled JSON file), and optional constructor parameters.call(Address contract, String method, Type<?>... inputs)
and call(Address contract, String data)
.as title
没有nft相关的java api吗
String hexAddress = AddressType.User.normalize(credentials.getAddress());
Address address = new Address(hexAddress, this.networkId);
if (this.exists(address)) {
return Optional.empty();
}
this.createKeyFile(password, credentials.getEcKeyPair());
return Optional.of(address);
这个address解密之后有地址,你这个if (this.exists(address)) 判断有地址然后制空吗,这正确吗,不应该是if (!this.exists(address))
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: okhttp3.RequestBody.create(Ljava/lang/String;Lokhttp3/MediaType;)Lokhttp3/RequestBody;
有没有标准的java的jar包提供,以及JavaApi、还有demo提供。首次接触这个东西,希望可以看到教程的demo
Hi folks,
I tried to use two threads to make different contract calls. Sometimes their responses may interfere with each other.
For this test, I defined the following class.
private class ContractCallThread extends Thread {
public ContractCallThread(ContractCall contract, String method, Type<?>... args) {
this.contract = contract;
this.method = method;
this.args = args;
}
public void run() {
this.result = this.contract.call(this.method, this.args).sendAndGet();
}
public String result() {
return this.result;
}
private ContractCall contract = null;
private String method = null;
private Type<?>[] args = null;
private String result = null;
}
The test code is as follows.
while (true) {
ContractCallThread getOutputsThread1 = new ContractCallThread(<contract_name>, <method_name>, <args_1>);
ContractCallThread getOutputsThread2 = new ContractCallThread(<contract_name>, <method_name>, <args_2>);
getOutputsThread1.start();
getOutputsThread2.start();
getOutputsThread1.join();
String result1 = getOutputsThread1.result();
<check_result1>
getOutputsThread2.join();
}
You'll soon get a result1 corresponding to args_2.
Could you please take a look? Thanks!
-linyufly
目前只有一个transfer函数以默认gas转账
public String transfer(String to, BigInteger value) throws Exception { BigInteger currentEpoch = this.cfx.getEpochNumber().sendAndGet(); RawTransaction tx = RawTransaction.transfer(this.nonce, to, value, currentEpoch); return this.mustSend(tx); }
Please refer to OkHttpClient
.
public String _mint(Option option, Address to, BigInteger tokenId) throws Exception {
return this.account.call(option, this.contract, "_mint", new Type[]{to, new Uint256(tokenId)});
}
public String _mint(Option option, CfxAddress to, BigInteger tokenId) throws Exception {
return this._mint(option, to.getABIAddress(), tokenId);
}
public String _mint(Option option, String to, BigInteger tokenId) throws Exception {
return this._mint(option, new Address(to), tokenId);
}
中并没有我想要的参数
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.