SuboptimalSend
A detector that identifies suboptimal message passing functions that could be replaced with more gas-effective alternatives.
Tact 1.6 introduced more gas-effective alternatives to send
that might
decrease gas consumption when used properly:
message
: a regular non-deployment messagedeploy
: an effective contract deployment functioncashback
: more efficient way to send the remaining balance
Why is it bad?
Using suboptimal send functions might lead to out-of-gas attacks, especially when using at hot points.
Example
let init = initOf SomeContract(p1, p2, p3);
send(SendParameters{
to: contractAddress(init),
code: init.code,
data: init.data,
value: 0,
body: FooBar{}.asCell(),
});
Use instead:
deploy(DeployParameters{
init: initOf SomeContract(p1, p2, p3),
value: 0,
body: FooBar{}.asCell(),
});