Post 400 Error When Trying To Generate DepositAddress

41 Views Asked by At

I am trying to use the getDepositAddress from the AxelarJS Sdk. As referenced here

const fromChain = CHAINS.TESTNET.POLYGON,
   toChain = CHAINS.TESTNET.AVALANCHE,
   destinationAddress = "0xF16DfB26e1FEc993E085092563ECFAEaDa7eD7fD",
   thisAsset = "wavax-wei";

 const depositAddress = await axelarAssetTransfer.getDepositAddress({
   fromChain,
   toChain,
   destinationAddress,
   thisAsset,
   options: {
     shouldUnwrapIntoNative: false,
   },
 });
 console.log(depositAddress);

This is the code I use on the frontend but the error in the picture is what pops up in the console browser.

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

Thank you for this. I got it working. I think the issue was that I was using a newer version of Nextjs and Rainbowkit/Wagmi and I do receive an error but finally receive the deposit address

0
On

It seems you received an error because the expected field was not passed into the get deposit address function or was incorrect.

What you did was:

 const depositAddress = await axelarAssetTransfer.getDepositAddress({
      fromChain,
      toChain,
      destinationAddress,
      thisAsset,
      options: {
        shouldUnwrapIntoNative: false,
      },
    });

Instead of

const depositAddress = await axelarAssetTransfer.getDepositAddress({
    fromChain,
    toChain,
    destinationAddress,
    asset: thisAsset,
    options: {
      shouldUnwrapIntoNative: false,
    },
  });

The key you provided for the asset was incorrect. I hope this helps!