method.send()

调用智能合约的非view和非pure方法。注意,该调用会修改智能合约状态。

用法

let contract = await tronWeb.contract.at('contractAddress'); 
let result = await contract.function_name(para1,para2,...).send({
    feeLimit:100_000_000,
    callValue:0,
  tokenId:1000036,
  tokenValue:100,
  shouldPollResponse:true
});

参数类型

参数描述数据类型
feeLimit调用合约方法消耗最大数量的SUN。上限是 10000 TRX。
(1TRX = 1,000,000SUN)
Integer
callValue本次调用往合约转账的TRX数量,以 SUN 为单位。Integer
shouldPollResponse如果设置为 TRUE,则会等到交易确认之后再返回结果。Boolean
tokenId本次调用往合约中转账TRC10的tokenId。如果没有,不需要设置String
tokenValue本次调用往合约中转账TRC10的数量,如果不设置tokenId,这项不设置。Integer

返回值类型
Object

示例

async function triggercontract(){
    try {
        let instance = await tronWeb.contract().at('TQQg4EL8o1BSeKJY4MJ8TB8XK7xufxFBvK');
        let res = await instance.transfer('TWbcHNCYzqAGbrQteKnseKJdxfzBHyTfuh',500).send({
            feeLimit:100_000_000,
            callValue:0,
            shouldPollResponse:true
        });

        console.log(res);

    } catch (error) {
        console.log(error);
    }
}

triggercontract();