Giter Site home page Giter Site logo

java-conflux-sdk's People

Contributors

boqiu avatar pana avatar tigo9527 avatar yangxianqi avatar yilinhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-conflux-sdk's Issues

conflux.web3j.RpcException: RPC error: code = -32015, message = Estimation isn't accurate: transaction is reverted.【放弃吧,换js-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);

Enhance the Account class for more utilities

Please help enhance the Account class with following utilities:

  1. Support deploy with file (e.g. truffle compiled JSON file), and optional constructor parameters.
  2. Resolve the method confliction: call(Address contract, String method, Type<?>... inputs) and call(Address contract, String data).

AccountManager imports(Credentials credentials, String password) 方法153行是不是有问题

	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))

It looks like sendAndGet() is not thread-safe

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

Account类transfer增加重载函数以便可以指定gas

目前只有一个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); }

在ERC721中铸造方法

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);
}

中并没有我想要的参数

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.