axelarnetwork / support

Your source for support with the Axelar Network
3 stars 1 forks source link

Getting an error using registerCanonicalInterchainToken #122

Closed cryshado closed 3 months ago

cryshado commented 3 months ago

Hi! I'm trying to call registerCanonicalInterchainToken on the InterchainTokenFactory contract, that is deployed on the Filecoin mainnet. I'm using this address, that I was found in the documentation:

const interchainTokenFactoryContractAddress = "0x83a93500d23Fbc3e82B410aD07A6a9F7A0670D66"

During this call:

await interchainTokenFactoryContract.registerCanonicalInterchainToken(tokenAddress)

I'm getting an error:

reason: 'failed to estimate gas: message execution failed: exit 33, revert reason: none, vm error: message failed with backtrace:\n' +
    '00: f02893565 (method 3844450837) -- contract reverted (33)\n' +
    '01: f02893565 (method 6) -- contract reverted (33)\n' +
    '02: f03136626 (method 3844450837) -- ABORT(pc=3190): undefined instruction (35)\n' +
    ' (RetCode=33)'

I tried making the same call with the Solidity contract and got the same error:

contract Helper is Ownable {
    address public constant _interchainTokenFactory = address(0x83a93500d23Fbc3e82B410aD07A6a9F7A0670D66);
    bytes32 public _tokenId;

    constructor() Ownable(msg.sender) {
        address token = address(0xacbc53BC8A640186b4d32F0e300DbB4CeaC17F77);
        _tokenId = ITokenFactory(_interchainTokenFactory).registerCanonicalInterchainToken(token);
    }
}
image

What could be the cause of the problem?

benjamin852 commented 3 months ago

Hey can you try set a gasLimit in your tx? Something like this: {gasLimit: "10000000" }. Also what's the address of the token you trying to register? Would like to see if I can replicate this error myself, thanks!

cryshado commented 3 months ago

@benjamin852 thank you for the reply. Just for the test I was trying to use a simple ERC20 smart contract:

pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC20, Ownable {
    constructor()
        ERC20("MyToken", "MTK")
        Ownable(msg.sender)
    {
        _mint(msg.sender, 10_000_000 * 10 ** 18);
    }
}

And I just deployed this ERC20 to Filecoin Calibration testnet:

0x35290AFD33E8F26b00FfC8a4383d7332b8d9e4C8

And then I'm getting the same error when calling registerCanonicalInterchainToken. By the way, I tried reproducing the same steps in Sepolia Testnet (Ethereum) and everything seems to work, so the problem doesn't look like a gas limit issue.

benjamin852 commented 3 months ago

Which environment are you running from? I tried to run the exact same code as you (on both sepolia and calibration) and it worked fine on both chains for me.

cryshado commented 3 months ago

@benjamin852 this code gives me an error:

interface ITokenFactory {
    function registerCanonicalInterchainToken(address tokenAddress) external payable returns (bytes32 tokenId);
}

contract Helper {
    address public constant _interchainTokenFactory = address(0x83a93500d23Fbc3e82B410aD07A6a9F7A0670D66);
    bytes32 public _tokenId;

    constructor() {
        address token = address(0x35290AFD33E8F26b00FfC8a4383d7332b8d9e4C8);
        _tokenId = ITokenFactory(_interchainTokenFactory).registerCanonicalInterchainToken(token);
    }
}
benjamin852 commented 3 months ago

Okay I was able to replicate now. There seems to be a problem with your token at address 0x35290AFD33E8F26b00FfC8a4383d7332b8d9e4C8. It works fine for me when I deploy a fresh token and pass in the address of that new token instead of 0x35290AFD33E8F26b00FfC8a4383d7332b8d9e4C8 in your constructor.

Also when I try to interact with the token at address 0x35290AFD33E8F26b00FfC8a4383d7332b8d9e4C8 on it's own I am unable to query a symbol or name for it so not really sure what's going on with that token. Easiest fix I think is just to use a new token and then it should work fine for you.

cryshado commented 3 months ago

@benjamin852 looks a little bit weird, now I can see the same - some of the functions on this ERC20 isn't callable. But I've tried to use the same ERC20 contract on other networks and it works fine. It might be something like Filecoin + ERC20 openzeppelin implementation specific issues. I will try to investigate it. Thank you for the feedback!

cryshado commented 3 months ago

UPD: Wiped everything out of Remix, tried it in a new environment, everything seems to be working. Strange... but ok :)