Estimate Fee/Pay Fees on destination chain

Fee information is checked on a contract called AnycallConfig

AnycallConfig Mainnets Address:

(Available Chains: Ethereum, Optimism, BNB Chain, Fantom, Polygon, Arbitrum, Avalanche)

0xc75b1860f553012a16de727b2bb2402aaf73eb03

AnycallConfig Testnet Address:

Goerli (5): 0x7EA2be2df7BA6E54B1A9C70676f668455E329d29

BNB Testnet (97): 0x5E2FeA0D1D06cD52cF949f1732bcC440AdCa459E

Fantom Testnet (4002): 0x470BFEE42A801Abb9a1492482d609fB84713d60F

Avalanche Fuji Testnet (43113): 0x6aB6d61428fde76768D7b45D8BFeec19c6eF91A8

Fees are handled in anyCallConfig contracts in V7.

Parameter for fee:

function anyCall( address _to, bytes calldata _data, uint256 _toChainID, uint256 _flags, bytes calldata )

The flags parameter determines the fee structure.

0: Gas fee paid on source chain. Fallback not allowed.

2: Gas fee paid on destination chain. Fallback not allowed.

4: Gas fee paid on source chain. Allow fallback

6: Gas fee paid on destination chain. Allow fallback

Fee paid on source chain.

When you use flag 0 or 4 in anyCall, you're paying fees on the source chain in gas tokens (Ether, BNB, MATIC etc).

function calcSrcFees(
        address _app,
        uint256 _toChainID,
        uint256 _dataLength
    ) external view returns (uint256) {
        string memory _appID = appIdentifier[_app];
        return _calcSrcFees(_appID, _toChainID, _dataLength);
    }

_app can be 0 when it's not specified.

_toChainID is the chain you're going to

_dataLength is the length of data you're passing to the funciton anycall

The amount of fee needed for such anyCall tx would then be returned. You can pass in that amount in the source chain tx.

Fee paid on destination chain.

When you use flag 2 or 6 in anyCall, you're indicating fees should be paid on the destination chain. This is done often to make UX more smooth by abstracting fees away for end users. The fees would be the exact gas cost used by the tx.

You would call the following function on the above contract on the destination chian to add fees.

_account would be your contract on the destination chain. This is different from V6.

function deposit(address _account) external payable { executionBudget[_account] += msg.value; emit Deposit(_account, msg.value); }

Example:

If I want to call anyCall from goerli to bnb testnet and my destination contract address for bnb testnet is 0xmock000000000000000000000000000000000000

I would call deposit(0xmock000000000000000000000000000000000000 ) with the appropriate gas fees.

If the gas fee isn't enough when you call anycall, the tx wouldn't execute until you top up with enough gas fees. This status would be reflected in the api.

Last updated