Smart contracts on ICON contain public interfaces. Other smart contracts that may want to make use of those interfaces can call them as if they were libraries. You can write some very complicated decentralized applications (dApps) with some very simple code by using public interfaces of useful smart contracts on ICON.
One smart contract can invoke an external method of another using the following APIs.
// [package score.Context]
public static Object call(Address targetAddress, String method, Object... params);
public static Object call(BigInteger value,
Address targetAddress, String method, Object... params);
The following example is for calling tokenFallback
.
if (_to.isContract()) {
Context.call(_to, "tokenFallback", _from, _value, dataBytes);
}