0

I installed Tronbox and want to deploy smart contract. But before that, I want to create a transaction for which I have private key and address. So, I installed tron-api-cli, followed instruction from link https://www.npmjs.com/package/tron-api-cli. But I am not getting how to create transaction in command line. Can somebody help? Even the tron-api-cli installation is completed, tron-api-cli command gives error:

tron-api-cli: command not found

4

1 回答 1

0

这个包有点名不副实。它不是命令行界面 (CLI),它是您可以在 Javascript 应用程序中使用的客户端。

要在 JS 中创建事务,请使用TransactionFactory。例如,查看AccountCLI 类的 sendTRX 方法:

sendTRX(toAddress,amount,node){
    pKeyRequired(this.pkey)
    let tx = TransactionFactory.createTx(TronProtocol.Transaction.Contract.ContractType.TRANSFERCONTRACT,{owner:this.address,to:toAddress,amount})
    return this.blockCli.addRef(tx).then((txWithRef)=>{
        let transactionString = this.sign(txWithRef,this.pkey)
        return axios.post(`${this.endpoint}${API_TRON_BROADCAST}`,{payload:transactionString,node}).then((res)=>{return res.data})            
    })
于 2019-03-06T13:45:29.923 回答