0

i'm trying to send ether to a smart contract with a specified amount of gas usage, the transaction sending works fine and it propagates to the network but remains pending forever not being executed as i see on rinkeby.etherscan.io. The code i use is this:

    Web3j web3j= Web3j.build(new HttpService("https://rinkeby.infura.io/ZE3AbqRo2GCvqu1WbY6O"));
    Credentials credentials = WalletUtils.loadCredentials(PASSWORD, WALLET_PATH);
    BigInteger nonce = web3j.ethGetTransactionCount("0x15Ced4F0b7C3fE42D680FD705aE369a9e986EA92", 
            DefaultBlockParameterName.LATEST).send().getTransactionCount();

    //Constructing transaction
    RawTransaction rawTransaction  = RawTransaction.createEtherTransaction(
            nonce, 
            new BigInteger("300"), 
            new BigInteger("50000"), 
            "0x5A47C8d694F4edb653Ff50139c91994f492C1d1e", 
            new BigInteger("200000000000000000")
    );

    //Signing transaction
    byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
    String hexValue = Numeric.toHexString(signedMessage);


    EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();
    String transactionHash = ethSendTransaction.getTransactionHash();

Is there something that i'm doing wrong ?

1 Answer 1

0

RawTransaction.createEtherTransaction(nonce, gas price, gas limit, toAddress, value);

Your Gas-Price is too low and remember it is in Wei.

BigInteger gasPrice = BigInteger.valueOf(2_000_000_000L);
RawTransaction rawTransaction  = RawTransaction.createEtherTransaction(
        nonce, 
        gasPrice, 
        new BigInteger("50000"), 
        "0x5A47C8d694F4edb653Ff50139c91994f492C1d1e", 
        new BigInteger("200000000000000000")
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.