1

I am following this tutorial for deployment of contract https://www.youtube.com/watch?v=ibAh04Csp0M&index=33&list=PL16WqdAj66SCOdL6XIFbke-XQg2GW_Avg

but i am getting

[RuntimeException: java.lang.NoSuchMethodException: smartcontract.Counter.<init>(java.lang.String, org.web3j.protocol.Web3j, org.web3j.crypto.Credentials, org.web3j.tx.gas.ContractGasProvider)]

on line

val deploy=Counter.deploy(web3j, credentials, GAS_PRICE, GAS_LIMIT).send()

here is my code

def getCredentials() :Credentials ={
    val private_key= "my main account address"
    val credentials= Credentials.create(private_key);
    credentials
  }

def deployContract(web3j: Web3j,credentials:Credentials/*transactionManager: TransactionManager*/):String ={
    val GAS_LIMIT = BigInteger.valueOf(6721975L);
    val GAS_PRICE = BigInteger.valueOf(20000000000L);
    val deploy = Counter.deploy(web3j, credentials, GAS_PRICE, GAS_LIMIT).send().getContractAddress
    deploy
    }

def counterContractDemo() = Action {
    val web3j = Web3j.build(new HttpService("http://localhost:8080/"))
    val deployAddress = deployContract(web3j,getCredentials)
    Ok(deployAddress)
  }

here is the piece of contract wrapped java code

Counter.java
public static RemoteCall<Counter> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(Counter.class, web3j, credentials, gasPrice, gasLimit, BINARY, "");
    }

    public static RemoteCall<Counter> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(Counter.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "");
    }

    public static Counter load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new Counter(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    public static Counter load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new Counter(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

i am running ethereum on privatenet please help what i am missing

  • have you included <script src="./node_modules/web3/dist/web3.min.js"></script> – iappmaker Dec 20 '18 at 14:27
  • where should i add this ? – swaheed Dec 21 '18 at 6:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.