Trigger OnReceive
Example 1
In this example, this account will only accept transfers of KCAL and reject anything else.
contract test {
trigger onReceive(from:address, symbol:string, amount:number)
{
if (symbol != "KCAL") {
throw "can't receive asset: " + symbol;
}
return;
}
}
Example 2
In this example, any asset sent to this account will be auto-converted into SOUL.
contract test {
import Call;
trigger onReceive(from:address, symbol:string, amount:number)
{
if (symbol != "SOUL") {
Call.contract("Swap", "SwapTokens", from, symbol, "SOUL", amount);
}
return;
}
}
Last updated