send()
Use send
to execute a non-pure
or modify
smart contract method on
a given smart contract that modifies or changes values on the blockchain.
These methods consume resources(bandwidth and energy) to perform as the
changes need to be broadcasted out to the network.
Usage
let abi = [...];
let contract = await tronWeb.contract(abi, 'contractAddress');
let result = await contract.function_name(para1,para2,...).send({
feeLimit:100_000_000,
callValue:0,
tokenId:1000036,
tokenValue:100,
shouldPollResponse:true
});
Parameters
Parameter | Description | Data Type |
---|---|---|
feeLimit | The maximum SUN consumes by calling this contract method. Hard capped at 10000 TRX. (1TRX = 1,000,000SUN) | Integer |
callValue | Amount of TRX transferred with this transaction, measured in SUN (1 TRX = 1,000,000 SUN). | Integer |
shouldPollResponse | If set to TRUE, this will wait until the transaction is confirmed on the solidity node before returning the result. | Boolean |
keepTxID | If both shouldPollResponse and keepTxID set to TRUE, the method will return txID and poll result. | Boolean |
pollTimes | If shouldPollResponse is set to TRUE, this will wait until the transaction is confirmed on the solidity node or the result has been polled the times specified by this parameter. | Integer |
tokenId | If the function accepts a trc 10 token ,then the id of the same | String |
tokenValue | Amount of token sent with the call. | Integer |
Returns
Object
Example
async function triggercontract(){
try {
let abi = [...];
let instance = await tronWeb.contract(abi, '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();