Web3j – Insufficient Funds Error on Deploying Smart Contract

web3j

I am writing a Java program to deploy a smart contract. I have created the Java Wrapper class. This is the essence of the code.

static final BigInteger GAS_PRICE = BigInteger.valueOf(20_000_000_000L);
static final BigInteger GAS_LIMIT = BigInteger.valueOf(4_300_000);
Credentials creds = WalletUtils.loadCredentials(password,
            pathtowalletfile);
Greeter contract = Greeter.deploy(web3j, creds, GAS_PRICE, GAS_LIMIT, BigInteger.ZERO, new Utf8String("Hello")).get();

When I run my program I am getting this error

Error processing transaction request: Insufficient funds for gas * price + value

I must say that I am quite new to ethereum and web3j. My geth version is 1.6.0-stable-facc47cb

Any help would be much appreciated.

Updated with Contract

contract mortal {
    address owner;

    function mortal()  { owner = msg.sender; }
    function kill() { if(msg.sender == owner) suicide(owner); }
}

contract greeter is mortal {
    string greeting;

    function greeter(string _greeting) public {
        greeting = _greeting;
    }

    function greet() constant returns (string) {
        return greeting;
    }
}

Best Answer

I am proposing you to define the gas value (higher value) :

static final BigInteger GAS = BigInteger.valueOf(30_000);


Greeter contract = Greeter.deploy(web3j, creds, GAS, GAS_PRICE, GAS_LIMIT, BigInteger.ZERO, new Utf8String("Hello")).get();