简体   繁体   中英

Can polygon smart contract call an Ethereum smart contract function?

pragma solidity ^0.8.0;
interface AnotherContract {
    function walletOfOwner(address owner) external view returns (uint256[] memory);
}

contract Test{
    uint public similarity;
    uint256 public hasRedPill;
    function test() public view returns(uint256  ){
       AnotherContract anotherContract = AnotherContract(address(0x116486FD64Ba04F7B789278B239E2e5A1e2f7b39));
      return anotherContract.walletOfOwner(msg.sender).length;
    }


}

The contract address I have used here already deployed on Ethereum blockchain.

I want to deploy the Test Contract on Polygon. But It seems it can not call the walletOfOwner() function. But it works fine if both the contract is deployed on same network. So, is there any way I can establish an inter-chain connection between these contracts.

I am very new to this. Please help.

So, is there any way I can establish an inter-chain connection between these contracts.

No, in practice, not possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM