I have been stuck here for a while now. I am tried to deploy my smart contract using the EthereumJ library. here are my codes:

pragma solidity ^0.4.22;

contract MyNotaryEntry {
    string fileName;
    uint timestamp;
    bytes32 checkSum;
    string comments;
    bool isSet;
    address setBy;

   modifier onlyOwner() {
        require(msg.sender == setBy);

    event NewEntry(bytes32 _checkSum,string _fileName,address indexed _setBy);

    function addEntry(bytes32 _checkSum,string memory _fileName,string memory _comments) public{

        checkSum = _checkSum;
        isSet = true;
        fileName = _fileName;
        timestamp = now;
        comments = _comments;
        setBy = msg.sender;

        emit NewEntry( checkSum , fileName, setBy );


    function entrySet() public view returns (string memory, uint, string memory, address){

        return(fileName, timestamp, comments , setBy);

the java code

    public TransactionReceipt sendTxAndWait(byte[] receiveAddress, byte[] data, byte[] senderPrivateKey)
        throws InterruptedException {
    System.out.println("senderPrivateKey" + ECKey.fromPrivate(senderPrivateKey).getAddress());
    BigInteger nonce = ethereum.getRepository().getNonce(ECKey.fromPrivate(senderPrivateKey).getAddress());

    Transaction tx = new Transaction(ByteUtil.bigIntegerToBytes(nonce),
            ByteUtil.longToBytesNoLeadZeroes(ethereum.getGasPrice()), ByteUtil.longToBytesNoLeadZeroes(3_000_000),
            receiveAddress, ByteUtil.longToBytesNoLeadZeroes(0), data, ethereum.getChainIdForNextBlock());

    logger.info("<=== Sending transaction: " + tx);
    ethereum.addListener(new EthereumListenerAdapter() {
        public void onBlock(Block block, List<TransactionReceipt> receipts) {
            super.onBlock(block, receipts);


    return waitForTx(tx.getHash());

public byte[] deployContracts(CompilationResult.ContractMetadata metadata, byte[] senderPrivateKey)
        throws InterruptedException {

    System.out.println("Sending contract to net and waiting for inclusion");

    receipt = transactionManager.sendTxAndWait(new byte[0], Hex.decode(metadata.bin), senderPrivateKey);

    if (!receipt.isSuccessful()) {
        System.out.println("Some troubles creating a contract: " + receipt.getError());


    byte[] contractAddress = receipt.getTransaction().getContractAddress();
    System.out.println("Contract created: " + toHexString(contractAddress));

    return contractAddress;

Below is the error i am constantly getting.

Sending contract to net and waiting for inclusion
Exception in thread "main" java.lang.NullPointerException
    at contract_service.compileContracts.deployContracts(compileContracts.java:87)
    at contract_service.compileContracts.compileContract(compileContracts.java:78)
    at contract_service.compile.main(compile.java:15)
  • Seems like you are not connected to a network? Or sth goes wrong when sending the Tx. – Curzon Dax Dec 28 '18 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.