public static Transaction createContractTransaction( String from, BigInteger nonce, BigInteger gasPrice, String init) { return createContractTransaction(from, nonce, gasPrice, null, null, init); }
@Override public Transaction buildTransaction() { return Transaction.createContractTransaction( validAccount(), BigInteger.ZERO, // nonce Transaction.DEFAULT_GAS, validContractCode() ); }
@Test public void testEthEstimateGasContractCreation() throws Exception { web3j.ethEstimateGas( Transaction.createContractTransaction( "0x52b93c80364dc2dd4444c146d73b9836bbbb2b3f", BigInteger.ONE, BigInteger.TEN, "")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_estimateGas\"," + "\"params\":[{\"from\":\"0x52b93c80364dc2dd4444c146d73b9836bbbb2b3f\"," + "\"gasPrice\":\"0xa\",\"data\":\"0x\",\"nonce\":\"0x1\"}],\"id\":1}"); }
private String sendTransaction() throws Exception { BigInteger nonce = getNonce(ALICE.getAddress()); Transaction transaction = Transaction.createContractTransaction( ALICE.getAddress(), nonce, GAS_PRICE, GAS_LIMIT, BigInteger.ZERO, getFibonacciSolidityBinary()); org.web3j.protocol.core.methods.response.EthSendTransaction transactionResponse = web3j.ethSendTransaction(transaction) .sendAsync().get(); return transactionResponse.getTransactionHash(); }
private String sendCreateContractTransaction() throws Exception { BigInteger nonce = getNonce(ALICE.getAddress()); String encodedConstructor = FunctionEncoder.encodeConstructor(Collections.singletonList(new Utf8String(VALUE))); Transaction transaction = Transaction.createContractTransaction( ALICE.getAddress(), nonce, GAS_PRICE, GAS_LIMIT, BigInteger.ZERO, getGreeterSolidityBinary() + encodedConstructor); org.web3j.protocol.core.methods.response.EthSendTransaction transactionResponse = web3j.ethSendTransaction(transaction) .sendAsync().get(); return transactionResponse.getTransactionHash(); }