axelarnetwork / support

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

Minting fails #83

Closed ekkis closed 7 months ago

ekkis commented 7 months ago

I'm building a proof-of-concept whereby I've created a token using the portal (which may be found here: https://testnet.interchain.axelar.dev/fantom/0xDEdbd54Ffc534a1aEC6D290E7FC5a337218D2708) and minted some tokens to my account

now I'm trying to do it using the API and here's what' I've cobbled together:

const hre = require("hardhat");
const {
  AxelarQueryAPI,
  Environment
} = require("@axelar-network/axelarjs-sdk");

const interchainTokenContractABI = require("./utils/interchainTokenABI");

async function getSigner() {
  const signers = await hre.ethers.getSigners();
    console.log(signers)
  return signers[0];
}

async function getContractInstance(contractAddress, contractABI, signer) {
  return new hre.ethers.Contract(contractAddress, contractABI, signer);
}

const api = new AxelarQueryAPI({ environment: Environment.TESTNET });
const TokenAddr = "0xDEdbd54Ffc534a1aEC6D290E7FC5a337218D2708"
const TokenMgrAddr = "0xB86E556574B5bf2A4e3E328Ecbb9EAc8e6F0Ce8E"

async function main() {
    const interchainToken = await getContractInstance(
        TokenAddr, interchainTokenContractABI, await getSigner()
    );

    console.log(interchainToken);

    // Initate transfer via token
    const res = await interchainToken.mint(
        "0xD5070f2a2C706C086407Ac8F3Bd4F21e3E46Cb99", 2000
    );
    console.log("Transfer Transaction Hash:", res.hash);
    console.log(JSON.stringify(res));
}

main().catch(err => {
    console.error(err)
    process.exitCode = 1
})

...which, when run, produces this:

{"_type":"TransactionResponse","accessList":[],"blockNumber":1,"blockHash":"0x2486af0977f0adb9ff358c7200357bcb03b2100bf3f6173e14a8c7f7738a8d0c","blobVersionedHashes":null,"chainId":"31337","data":"0x40c10f19000000000000000000000000d5070f2a2c706c086407ac8f3bd4f21e3e46cb9900000000000000000000000000000000000000000000000000000000000007d0","from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","gasLimit":"30000000","gasPrice":"1875000000","hash":"0xb437d1a075f998664445d010241bb8e14f527ca62636a3b5f39e5f46c76799e8","maxFeePerGas":"2750000000","maxPriorityFeePerGas":"1000000000","maxFeePerBlobGas":null,"nonce":0,"signature":{"_type":"signature","networkV":null,"r":"0xf77742adb4d92b1c1d68b0465bceef51ab66e71ec509ad86e893b5a8b99a3289","s":"0x2cd87c119a2b1be0bcd2bce5af149d4758bc7cf1de9f8ea65058ec67b541904e","v":27},"to":"0xDEdbd54Ffc534a1aEC6D290E7FC5a337218D2708","type":2,"value":"0"}

...however, I never receive the tokens. as can be seen from the above, there is a transaction hash generated but then I look it up on AxelarScan it doesn't find it (see: https://testnet.axelarscan.io/gmp/0xb437d1a075f998664445d010241bb8e14f527ca62636a3b5f39e5f46c76799e8). it also doesn't find it on FantomScan (I'm not entirely sure where to look): https://testnet.ftmscan.com/tx/0xb437d1a075f998664445d010241bb8e14f527ca62636a3b5f39e5f46c76799e8

so I gather the transaction is not being broadcast. am I missing something in the code,. or is there some configuration thing I'm missing?

the address I'm sending to received the tokens I minted through the portal but never receives the ones issued by the code

thanks in advance

-- ekkis

ekkis commented 7 months ago

incidentally, if I change the address of the contract to use that of the token manager contract, I get the same effect -- no tokens minted. here's the output from the transaction:

{"_type":"TransactionResponse","accessList":[],"blockNumber":1,"blockHash":"0xe22945792cb2f4314f04c63e7aaee5402690820d662e4ca4413b067222a509f8","blobVersionedHashes":null,"chainId":"31337","data":"0x40c10f19000000000000000000000000d5070f2a2c706c086407ac8f3bd4f21e3e46cb9900000000000000000000000000000000000000000000000000000000000007d0","from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","gasLimit":"30000000","gasPrice":"1875000000","hash":"0xe6beeb1042545565d18091b558e0c8c5cd3e552488295ac3598743d1f891c8e1","maxFeePerGas":"2750000000","maxPriorityFeePerGas":"1000000000","maxFeePerBlobGas":null,"nonce":0,"signature":{"_type":"signature","networkV":null,"r":"0xd1afba03fa9237aaaab4d96d8440833449d6485056d317fbcf404bcab49e3439","s":"0x7fd41090fa2b3334fcbb21f1f367d9efdb5027c088746be619138bfa34330cce","v":27},"to":"0xB86E556574B5bf2A4e3E328Ecbb9EAc8e6F0Ce8E","type":2,"value":"0"}

ekkis commented 7 months ago

so what I don't understand is: how does this code know which account is signing the transaction? it needs to have access to a private key to do it and I haven't provided one. I get the sense that hre.ethers.getSigners() is a list of Axelar approved keys but if I'm generating the transaction, I need to sign it and my code doesn't provide that. so what am I missing?

ekkis commented 7 months ago

ok. I figured out the problem. I was following this guide: https://docs.axelar.dev/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-token, which declares a hardhat.config.js without a default network. when adding defaultNetwork: "fantom", it allowed broadcasting of transactions. it all works now

Olanetsoft commented 7 months ago

That's a great news. Thanks for the feedback.