soliditytrontrxtronlink

How to send TRX to a smart contract function in tronlink web


How can I send tron to a smart contract function in tronlink web. I am trying the below method, but not working.

var contract = await tronweb.contract().at('{{env('CONTRACT_ADDRESS')}}')
await contract.Invest({{session('member_id')}}).address.send(amount);

it's calling the smart contract function but not sending tron.


Solution

  • callValue - Amount of SUN transferred to the contract with this transaction. (1TRX = 1,000,000 SUN)

    await contract.Invest({{session('member_id')}}).send({callValue: amount})
    

    You can check tronweb documentation for send () parameters.