0

I am building a cross chain swap dapp with chainlink ccip. Basically user1 creates an order on chain A and its acceptable from any chain. When I send acceptOffer from chainB (since it's local it's just a term) I send funds from chain B to chainA, then chainA sends back funds to chainB. Also I add a second cross token send for paying ccip fees on chainA. This ccip message goes without a problem. The second message I get this error :

 │ │ │ │ ├─ [47706] MockCCIPRouter::ccipSend(16015286601757825753 [1.601e19], EVM2AnyMessage({ receiver: 0x0000000000000000000000001d1499e622d69689cdf9004d05ec547d650ff211, data: 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000ff93edfa7fb7ad5e962e4c0edb9207c03a0fe020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dfa97bfe5d2b2e8169b194eaa78fbb793346b1740000000000000000000000002e234dae75c793f67a35089c9d99245e1c58470b000000000000000000000000ddc10602782af652bb913f7bde1fd82981db7dd9000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000002c68af0bb1400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e110000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000411c89beb29ef208c7220e35cb0f468298c705d2ed59a576509200e1e1bf13c94b2c7c6f0ad97d18ae3bf5955cae53fa59fa4dac277b80dc43748be8e33372be4f1c00000000000000000000000000000000000000000000000000000000000000, tokenAmounts: [EVMTokenAmount({ token: 0x2e234DAe75C793f67A35089C9d99245E1C58470b, amount: 99750000000000000 [9.975e16] })], feeToken: 0x037eDa3aDB1198021A9b2e88C22B464fD38db3f3, extraArgs: 0x181dcf1000000000000000000000000000000000000000000000000000000000009896800000000000000000000000000000000000000000000000000000000000000001 })) │ │ │ │ │ ├─ [7254] LinkToken::transferFrom(Pexo: [0xA4AD4f68d0b91CFD19687c881e50f3A00242828c], MockCCIPRouter: [0xfD07C974e33dd1626640bA3a5acF0418FaacCA7a], 0) │ │ │ │ │ │ ├─ emit Approval(owner: Pexo: [0xA4AD4f68d0b91CFD19687c881e50f3A00242828c], spender: MockCCIPRouter: [0xfD07C974e33dd1626640bA3a5acF0418FaacCA7a], value: 0) │ │ │ │ │ │ ├─ emit Transfer(from: Pexo: [0xA4AD4f68d0b91CFD19687c881e50f3A00242828c], to: MockCCIPRouter: [0xfD07C974e33dd1626640bA3a5acF0418FaacCA7a], value: 0) │ │ │ │ │ │ └─ ← [Return] true │ │ │ │ │ ├─ [25334] MockERC20::transferFrom(Pexo: [0xA4AD4f68d0b91CFD19687c881e50f3A00242828c], Pexo: [0x1d1499e622D69689cdf9004d05Ec547d650Ff211], 99750000000000000 [9.975e16]) │ │ │ │ │ │ ├─ emit Transfer(from: Pexo: [0xA4AD4f68d0b91CFD19687c881e50f3A00242828c], to: Pexo: [0x1d1499e622D69689cdf9004d05Ec547d650Ff211], value: 99750000000000000 [9.975e16]) │ │ │ │ │ │ └─ ← [Return] true │ │ │ │ │ ├─ [255] Pexo::supportsInterface(0x01ffc9a7) [staticcall] │ │ │ │ │ │ └─ ← [Return] true │ │ │ │ │ ├─ [255] Pexo::supportsInterface(0xffffffff) [staticcall] │ │ │ │ │ │ └─ ← [Return] false │ │ │ │ │ ├─ [229] Pexo::supportsInterface(0x85572ffb) [staticcall] │ │ │ │ │ │ └─ ← [Return] true │ │ │ │ │ └─ ← [Revert] NotEnoughGasForCall() │ │ │ │ └─ ← [Revert] NotEnoughGasForCall() │ │ │ ├─ emit MessageFailed(messageId: 0x743c028cab782d098980d3116f06287147a7dea13bb435f57b7b7a13b0fd6243, reason: 0x37c3be29) │ │ │ └─ ← [Stop] │ │ ├─ emit MsgExecuted(success: true, retData: 0x, gasUsed: 892069 [8.92e5]) │ │ ├─ emit MessageExecuted(messageId: 0x743c028cab782d098980d3116f06287147a7dea13bb435f57b7b7a13b0fd6243, sourceChainSelector: 16015286601757825753 [1.601e19], offRamp: Pexo: [0x1d1499e622D69689cdf9004d05Ec547d650Ff211], calldataHash: 0x5a5cc7962e816fcd7330e1fdb1c5ccec2d7fab86e50c1807e07d55b2a8716411) │ │ └─ ← [Return] 0x743c028cab782d098980d3116f06287147a7dea13bb435f57b7b7a13b0fd6243 │ ├─ emit MessageSent(messageId: 0x743c028cab782d098980d3116f06287147a7dea13bb435f57b7b7a13b0fd6243, destinationChainSelector: 16015286601757825753 [1.601e19], receiver: Pexo: [0xA4AD4f68d0b91CFD19687c881e50f3A00242828c], token: BurnMintERC677Helper: [0xDDc10602782af652bB913f7bdE1fD82981Db7dd9], tokenAmount: 200000000000000000 [2e17], feeToken: 0x0000000000000000000000000000000000000000, fees: 0) │ ├─ emit Swap(sig: 0x1c89beb29ef208c7220e35cb0f468298c705d2ed59a576509200e1e1bf13c94b2c7c6f0ad97d18ae3bf5955cae53fa59fa4dac277b80dc43748be8e33372be4f1c, tokenIn: MockERC20: [0x2e234DAe75C793f67A35089C9d99245E1C58470b], tokenOut: BurnMintERC677Helper: [0xDDc10602782af652bB913f7bdE1fD82981Db7dd9], tokenInAmount: 0, tokenOutAmount: 200000000000000000 [2e17], buyer: buyer: [0x0fF93eDfa7FB7Ad5E962E4C0EdB9207C03a0fe02], seller: seller: [0xDFa97bfe5d2b2E8169b194eAA78Fbb793346B174], isPartial: false, partialAmount: 200000000000000000 [2e17], isVesting: false, vestingDuration: 0, vestingId: 0, chainId: 31337 [3.133e4]) 

To fix this error i tried: give all contracts to 100 ether and link token. I was using weth for fees change to link token. Nothing help.

This is the first ccip message successful one.

 function _calculateAndSendReCallFees( uint256 _reCallGasTokenAmount, IRouterClient _router, CrossChainData memory _crossChainData, address _destinationContract, uint64 _destinationChainSelector ) internal { // Get maximum ETH needed for the exact fee token amount uint256 maxEthNeeded = IFeeTokenPurchaser(s_feeTokenPurchaser) .getMaximumAmountIn(_reCallGasTokenAmount); // Purchase exact amount of fee tokens with calculated ETH amount IFeeTokenPurchaser(s_feeTokenPurchaser).purchaseExactFeeTokenWithETH{ value: maxEthNeeded }(s_feeToken, _reCallGasTokenAmount, address(this)); // Now send the fee tokens via CCIP IERC20(s_feeToken).approve(address(_router), _reCallGasTokenAmount); Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({ receiver: abi.encode(_destinationContract), data: abi.encode(_crossChainData), tokenAmounts: _buildTokenAmounts(s_feeToken, _reCallGasTokenAmount), extraArgs: ccipExtraArgs, feeToken: address(0) }); uint256 fees = _router.getFee(_destinationChainSelector, message); console.log("fees", fees); _router.ccipSend{value: fees}(_destinationChainSelector, message); } 

Here is rest of the code:

 _calculateAndSendReCallFees( reCallGasTokenAmount, router, crossChainData, destinationContract, destinationChainSelector ); crossChainData.isFeePayment = false; // Create CCIP message Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({ receiver: abi.encode(destinationContract), data: abi.encode(crossChainData), tokenAmounts: _buildTokenAmounts(tokenAddress, partialAmount), extraArgs: ccipExtraArgs, feeToken: address(0) }); uint256 fees = router.getFee(destinationChainSelector, message); // Send via CCIP bytes32 messageId = router.ccipSend{value: fees}( destinationChainSelector, message ); emit MessageSent( messageId, destinationChainSelector, destinationContract, tokenAddress, partialAmount, address(0), fees ); 

Set extraArgs like this: ( 10_000_000 overkill i know. 400_00 gives also outOfGas error over 800_00 doesnt give that error. )

 contract.setCcipExtraArgs( Client._argsToBytes( Client.GenericExtraArgsV2({ gasLimit: 10_000_000, allowOutOfOrderExecution: true }) ) ); 

console.log( "fees" , fees ) return 0 by the way so technically I don't need to send any fees for ccip on local tests.

6
  • Hi Furkan, what is feetoken referred to in our first snippet codes? In CCIP message, native token and link token can be used as fee token to pay ccip fee. what do you mean by "Also i add a second cross token send for paying ccip fees on chainA." Commented Aug 6 at 9:40
  • @FrankKong hi, I feeToken is, the tokens to pay ccip fee on the return message. Users send a message from chain A to chain B. On chain B, when a message is received, chainB sends a message to chainA. This requires ccip fees. So when users send their first message on chainA they also sends some tokens as feeToken. For most of the chain it will be link token. Commented Aug 7 at 13:36
  • @FrankKong i solved the issue by setting gas limit on contract on chainB to 400_000. Kept 1_000_000 gas limit contract on chainA. No idea why it worked. Commented Aug 7 at 13:41
  • What was the gas limit on ChainB previously? You decrease or increase the gas limit? Commented Aug 7 at 14:09
  • I decreased to 400_000. I used to set same gas limit for both chains. On chainA i kept 1_000_000 gas limit and on chainB i set 400_000 Commented Aug 8 at 15:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.