If the anyExec contract execution failed on Chain B, it can call _fallback function to send messages back to Chain A.

anyExecute DAPP receiver contract(Chain B failed) -> anyCall(Chain B) -> SMPC Network -> anyExec(Chain A) -> anyExecute (DAPP sender contract(Chain A))


Format of the fallback function needs to be:

function anyFallback(address _to, bytes calldata _data) external;


When anyExecute fails on Chain B, the anycall contract would issue another call back to chain A with data including the anyFallback selector.

Hence the anyExecute execute normal function or fallback function based on the selector.

emit LogAnyCall(
                abi.encodeWithSelector(IApp.anyFallback.selector, _to, _data),
                0, // pay fee on dest chain


Example Contract Code:

2. Chain B issued callback:

3. anyFallback executing:

anyExecute function:

When executing, anyExecute first look at the selector of the calldata passed in to determine if it should execute normal flow or fallback function.

function anyExecute(bytes calldata data)
        returns (bool success, bytes memory result)
        bytes4 selector = bytes4(data[:4]);
        if (selector == this.anyExecute.selector) {
                string memory message
            ) = abi.decode(

            if (compareStrings(message,"fail")){
                return (false, "fail on purpose");

            emit NewMsg(message);
        } else if (selector == this.anyFallback.selector) {

            // original data with selector would be passed here if thats the case
            (address _to, bytes memory _data) = abi.decode(data[4:], (address, bytes));
            this.anyFallback(_to, _data);
        } else {
            return (false, "unknown selector");
        return (true, "");

Last updated