[RuntimeException:java.lang.NoSuchMethodException:使用web3j的SmartContract

时间:2018-12-21 11:31:51

标签: java scala ethereum web3js go-ethereum

我正在按照本教程进行合同https://www.youtube.com/watch?v=ibAh04Csp0M&index=33&list=PL16WqdAj66SCOdL6XIFbke-XQg2GW_Avg的部署

但是我得到

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

在线

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

这是我的代码

def getCredentials():凭据= {     val private_key =“我的主要帐户地址”     val certificate = Credentials.create(private_key);     证书   }

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)
  }

这是合同包装的Java代码

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);
    }

我正在Privatenet上运行以太坊,请帮助我所缺少的内容

0 个答案:

没有答案