I'm trying to send funds to a smart contract using the following code, however, the balance is always 0.

TransactionReceipt transactionReceipt = Transfer.sendFunds(
            web3j, credentials, recipient,
            amount, Convert.Unit.WEI)
EthGetBalance contractGetBalance = web3j.ethGetBalance(recipient, DefaultBlockParameterName.LATEST)
    BigInteger contractBalance = contractGetBalance.getBalance();

Why doesn't it go through? The smart contract code is:

pragma solidity ^0.4.7;

contract ReceiveContract {
  address public owner;

  function ReceiveContract() public {
    owner = msg.sender;

  function () payable public {

  • Do you get any error? What is the smart contract code? Commented Jan 16, 2018 at 5:50
  • I edited the original question to add the smart contract code. Also, as far as I can tell, I am not getting any error
    – yemista
    Commented Jan 16, 2018 at 13:51

1 Answer 1


So I found a solution, and it was to change my send code to use raw transactions

    EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount(
            credentials.getAddress(), DefaultBlockParameterName.LATEST).sendAsync().get();
    BigInteger nonce = ethGetTransactionCount.getTransactionCount();
    RawTransaction rawTransaction  = RawTransaction.createEtherTransaction(
             nonce, ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT, recipient, amount);
    byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
    String hexValue = Numeric.toHexString(signedMessage);
    EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();

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.