Web3j
部署智能合約時資金不足錯誤
我正在編寫一個 Java 程序來部署智能合約。我創建了 Java Wrapper 類。這就是程式碼的本質。
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();
當我執行我的程序時,我收到了這個錯誤
處理交易請求時出錯:gas * price + value 資金不足
我必須說我對乙太坊和 web3j 很陌生。我的 geth 版本是 1.6.0-stable-facc47cb
任何幫助將非常感激。
已更新契約
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; } }
我建議你定義氣體值(更高的值):
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();