Invocation failed: "Reentrant call" - Intercontract call failure in Sophia

Hello All,
I am trying to use the AEX-141 NFT standard for one of the projects that I am building.(here is the SC link from aeternity - aex141-examples/base_nft.aes at dev · aeternity/aex141-examples · GitHub).

My requirement is to interact with the deployed nft contract(whose address is passed in as a param) to my base contract and my base contract(a marketplace sortof) be controlling the nft’s ownership and other attributes.
But when I am making a intercontract contract call(my base contract to already deployed nft contract), I am getting an exception shown below.

Here is my base contract:

@compiler >= 6

include "String.aes"
include "Option.aes"
include "List.aes"
include "core/interfaces.aes"

payable contract SampleNFTInterContract =

    function tokensTransferable(_token : NFT, _tokenId : int) : bool =
        require(_token.is_approved_for_all(Call.caller, Contract.address) == true, "The HTLC contract must have been designated as an approved spender for the token")
        true
    
    public payable stateful entrypoint newContract(_tokenContract: NFT, _tokenId : int) : int = 
        tokensTransferable(_tokenContract, _tokenId)
      

What can be reason for this exception? How do I make the inter-contract call?

1 Like

The error means that you have contract A that calls contract B and then contract B calls back into contract A - this is not allowed in Sophia/FATE.

2 Likes

Hi @hanssv.chain ,
in my contract B(NFT Contract), I am not making any other inter-contract calls.
My contract A from where I am trying to invoke B is the only inter-contract call and I am sure of it.

Given the situation, what do you think would be causing this?

1 Like

You asked what the error meant, and I explained that. I have not looked at your particular example and I have no insight there, sorry.

2 Likes

Maybe @zkvonsnarkenstein.chain could help here as this is an AEX-141 contract?

I don’t think that this is a bug with the AEX-141 contract. @hanssv.chain already explained the cause of this error. The contracts seem to be calling each other and that’s not allowed. Since I only see a tiny snippet of the code, it’s not possible to determine where this happens exactly.

4 Likes

@Jkrish1011 that might indeed have been an issue with the initial state of the standard where this scenario has not been covered.

this is why transfer_to_contract entrypoint has been introduced, see AEXs/aex-141.md at master · aeternity/AEXs · GitHub

here a simple marketplace implementation that makes use of it:

just discovered this old thread and maybe the info is helpful to somebody out there :slight_smile:

2 Likes

@marco.chain Thanks for your input.
I will have a look at the latest AEX-141 standard do the necessary changes as needed.

thanks again!

2 Likes