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

Varsh
  • 413
  • 9
  • 26

1 Answers1

0

The package is kind of misnamed. It's not a Command Line Interface (CLI), it's a client that you can use inside a Javascript application.

To create a transaction in JS, you use the TransactionFactory. For example, see the method sendTRX from AccountCLI class:

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})            
    })
Sigmatics
  • 615
  • 4
  • 17