1

I use SimpleMultiSig to generate java code with web3j. When I call the execute() function after 600s throw the error org.web3j.protocol.exceptions.TransactionException: Transaction receipt was not generated after 600 seconds for transaction: 0x3bfd850eb07a210af01c9321adf0ed2ac8f483b753ec2df2b641f911ab0d51d2; I have changed the gas_price but it not work; my source code is that witch refer this code and that code:

    private static BigInteger GAS_LIMIT = BigInteger.valueOf(300000L);

    public String withdraw(String privateKey, List<String> signers, String multiAddress, String desAddress, BigDecimal amount,
                           String executor, String data){
        try {
            BigInteger once  = this.getOnce(multiAddress);

            BigInteger withdrawAmount = Convert.toWei(amount, Convert.Unit.ETHER).toBigInteger();
            String nameHash = NAME_HASH.substring(2);
            String versionHash = VERSION_HASH.substring(2);

            String domainData = EIP712DOMAINTYPE_HASH + nameHash + versionHash +
                    String.format("%064d", chainId) + String.format("%064d", new BigInteger(multiAddress.substring(2),16)) +
                    SALT.substring(2);

            BigInteger ethGasPrice = this.getGasPrice();
            String domainSeparator = Hash.sha3(domainData);
            String txInput = TXTYPE_HASH + String.format("%064d", new BigInteger(desAddress.substring(2),16)) +
                    String.format("%064d", withdrawAmount) + Hash.sha3(data).substring(2) +
                    String.format("%064d", once) + String.format("%064d", new BigInteger(executor.substring(2),16)) +
                    String.format("%064d", GAS_LIMIT);
            String txInputHash = Hash.sha3(txInput);
            String input = "0x1901" + domainSeparator + txInputHash;
            String hash = Hash.sha3(input);

            List<BigInteger> signV = new ArrayList<>();
            List<byte[]> signR = new ArrayList<>();
            List<byte[]> signS = new ArrayList<>();
            for(String singer: signers){
                Credentials credentials = Credentials.create(singer);
                Sign.SignatureData signature = Sign.signMessage(Numeric.hexStringToByteArray(hash),credentials.getEcKeyPair(),
                        false);

                signV.add(Numeric.toBigInt(signature.getV()));
                signR.add(signature.getR());
                signS.add(signature.getS());
            }
            SimpleMultiSig contract = this.loadContract(privateKey);
            TransactionReceipt receipt = contract.execute(signV,signR, signS,desAddress,withdrawAmount,
                    data.getBytes(),executor,GAS_LIMIT).send();
            return receipt.getTransactionHash();
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException();
        }
    }
    private SimpleMultiSig loadContract(String privateKey) throws Exception{
        HttpService httpService = new HttpService(nodeUrl);
        Web3j web3j = Admin.build(httpService);

        BigInteger privateBigInteger = new BigInteger(privateKey,16);
        ECKeyPair ecKeyPair = ECKeyPair.create(privateBigInteger);
        Credentials credentials = Credentials.create(ecKeyPair);
        BigInteger ethGasPrice = web3j.ethGasPrice().send().getGasPrice();
        StaticGasProvider gasProvider = new StaticGasProvider(ethGasPrice, GAS_LIMIT);

        SimpleMultiSig contract = SimpleMultiSig.load(contractAddress, web3j, credentials, gasProvider);

        return contract;
    }

    public BigInteger getOnce(String address)throws Exception{
        HttpService httpService = new HttpService(nodeUrl);
        Web3j web3j = Admin.build(httpService);

        EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount(
                address, DefaultBlockParameterName.LATEST).send();

        return ethGetTransactionCount.getTransactionCount();
    }

    public BigInteger getGasPrice()throws Exception{
        HttpService httpService = new HttpService(nodeUrl);
        Web3j web3j = Admin.build(httpService);

        return web3j.ethGasPrice().send().getGasPrice();
    }

And I use rinkeby

4
  • 1
    "I have changed the gas_price" - your code shows otherwise (using the network's default). Your transaction can pend more than 600 seconds if your gas-price isn't high enough to get it done more quickly. – goodvibration May 6 '20 at 7:13
  • 1
    thank u for your anwser @goodvibration. The code above is the first version. the highest gas price i have used isBigInteger ethGasPrice = web3j.ethGasPrice().send().getGasPrice().multiply(BigInteger.valueOf(2000)); but that not work – new_fish May 6 '20 at 7:50
  • 1
    I'm not familiar with web3j, but web3j.ethGasPrice().send().getGasPrice() looks dubious at best. – goodvibration May 6 '20 at 7:59
  • 1
    at first I use web3j.ethGasPrice().send().getGasPrice() but the same error =.=!. – new_fish May 6 '20 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.