我安装了Tronbox,并希望部署智能契约。但在此之前,我希望创建一个具有私钥和地址的事务。因此,我安装了tron-api-cli,遵循来自链接https://www.npmjs.com/package/tron-api-cli的指示。但我不知道如何在命令行中创建事务。有人能帮忙吗?即使tron cli安装已经完成,tron cli命令也会出现错误:
tron-api-cli:未找到命令
发布于 2019-03-06 13:45:29
这个包裹的名字有点不正确。它不是命令行接口(命令行接口,CLI),而是可以在Javascript应用程序中使用的客户机。
要在JS中创建事务,可以使用TransactionFactory。例如,请参见来自AccountCLI类的方法AccountCLI类。
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})
})https://stackoverflow.com/questions/54879551
复制相似问题