2

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;
    }
}
2
  • check your account balance do you have any ethers?
    – Badr Bellaj
    May 4, 2017 at 11:03
  • Yes, I have. 6.95485869776e+21 is the balance in my account. May 4, 2017 at 11:06

1 Answer 1

1

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();
6
  • I tried static final BigInteger GAS = BigInteger.valueOf(30_000); Greeter contract = Greeter.deploy(web3j, creds, GAS, GAS_LIMIT, BigInteger.ZERO, new Utf8String("Hello")).get(); But I still am running into the same error. May 4, 2017 at 11:37
  • what is the estimated gas of your contract?
    – Badr Bellaj
    May 4, 2017 at 11:43
  • estimated gas is 47123. I increased my gas value to 50000. Still I am getting the same error. May 4, 2017 at 12:57
  • share with me your contract if it is possible
    – Badr Bellaj
    May 4, 2017 at 14:18
  • I have updated the contract in the question. Thank you for the help. May 5, 2017 at 3:56

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.