xuperchain / xuperchain

A highly flexible blockchain architecture with great transaction performance.

Home Page:https://xuper.baidu.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

createContractAccount 创建合约账号失败

bookc-man opened this issue · comments

异常信息
java.lang.RuntimeException: io.grpc.StatusRuntimeException: UNKNOWN: Err:500-50501-contract invoke failed+identity check failed at com.baidu.xuper.api.Proposal.build(Proposal.java:198) at com.baidu.xuper.api.XuperClient.invokeContract(XuperClient.java:140) at com.baidu.xuper.api.XuperClient.createContractAccount(XuperClient.java:264)

创建代码

        System.out.println("\n初始化超级链");
        File directory = new File("");
        //规范路径:getCanonicalPath()方法返回绝对路径
        String rootCanonicalPath = directory.getCanonicalPath();
        //绝对路径:getAbsolutePath()方法返回文件的绝对路径,如果创建的时候使用的绝对路径返回绝对路径,创建的时候使用的相对路径,返回相对路径
        rootAbsolutePath = directory.getAbsolutePath();
        String confPath = rootAbsolutePath + "/baidu/src/main/resources/key/sdk.yaml";
        Config.setConfigPath(confPath);
        xuperClient = new XuperClient("39.156.69.83:37100");
        String privateKey = rootCanonicalPath + "/baidu/src/main/resources/key";//不用加private.key
        account = Account.getAccountFromFile(privateKey, secritStr);
        //添加合约账户
        account.setContractAccount(contractAccount);

        Account newAccount = Account.create(1, 2);
        System.out.println(newAccount.getAddress());
        System.out.println(newAccount.getMnemonic());
        Transaction createContractAccountTX = xuperClient.createContractAccount(newAccount, "32080219920806157");
        System.out.println("txid: " + createContractAccountTX.getTxid());
        System.out.println("response: " + createContractAccountTX.getContractResponse().getBodyStr());
        System.out.println("gas: " + createContractAccountTX.getGasUsed() + "\n");
commented

xuperos 无法使用本地创建的账号发送交易,需要使用私钥恢复的 account,创建合约账户等操作也必须使用该账号,在你的代码中,newAccount 是不可用的。可以使用 account。