axelarnetwork / support

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

Send token problem #101

Closed Lukols-Dev closed 3 months ago

Lukols-Dev commented 3 months ago

Hi,

I dont have reason. I have error:

reason: 'transaction failed', code: 'CALL_EXCEPTION',

I want to use sandToMany to send tokens (aUSDC) between Sepolia -> Mumbai. What could I be doing wrong?

const sendTx = await contract.sendToMany( destinationChain, //Poligon destinationAdress, //deployed contract in Mumbai adressess, //wallet addres in [] symbol, // "aUSDC" amount, //ethers.utils.parseUnits("1", 6) { value: ethers.utils.parseEther("0.01"), gasLimit: 200000, }, );

Lukols-Dev commented 3 months ago

Its my contract:

//SPDX-License-Identifier: MIT pragma solidity ^0.8.9;

import {AxelarExecutable} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/executable/AxelarExecutable.sol"; import {IAxelarGateway} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol"; import {IERC20} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol"; import {IAxelarGasService} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol";

/**

Lukols-Dev commented 3 months ago

and its my script to send token Sepolia->Mumbai:

import { ethers } from "hardhat"; import { AxelarQueryAPI, Environment, EvmChain, GasToken } from "@axelar-network/axelarjs-sdk";

async function main() { const destinationAdress = "0x22BfB01f2831A717DFc8053Fd29F45EDaDff9960"; //deployed contract in Mumbai const destinationChain = "Polygon"; // Nazwa łańcucha docelowego const adressess = ["0x1e147BA822892748ED2A8952C582e4da4A3200ff"]; //wallet address const symbol = "aUSDC"; // Symbol tokena, który chcesz wysłać const amount = ethers.utils.parseUnits("1", 18); // Łączna ilość tokenów do wysłania, pamiętaj o dostosowaniu do liczby miejsc dziesiętnych dla USDC

// Pobranie instancji Twojego kontraktu const contract = await ethers.getContractAt( "CallContractWithToken", "0xe1C0C45A4B2C80D266e39751ECfEaEa7065ca963", //Deployed contract in Sepolia );

// Szacowanie Gas przed wysłaniem const api = new AxelarQueryAPI({ environment: Environment.TESTNET });

const estimatedGas = await api.estimateGasFee( "ethereum-sepolia", EvmChain.POLYGON, GasToken.ETH, 700000, 2, );

console.log("Estimate gas: ", estimatedGas);

const sendTx = await contract.sendToMany( destinationChain, destinationAdress, adressess, symbol, amount, { value: BigInt(3000000), gasLimit: 200000, }, ); await sendTx.wait();

console.log(Initialize: ${sendTx.hash}); }

main().catch((error) => { console.error(error); process.exit(1); });

Olanetsoft commented 3 months ago

Thanks for creating an issue. Is this the complete contract code? It looks like there is no _executeWithToken function. Also, I can see you have sendToMany and sendToken. Which one are you using?

Lukols-Dev commented 3 months ago

I would like to use sendToMany. is placed _executeWithToken

Lukols-Dev commented 3 months ago

unless you want it to look different, the contract is what was in example-web for call-contract-with-token

Olanetsoft commented 3 months ago

Looking at the execution script, This ethers.utils.parseUnits("1", 18); should be ethers.utils.parseUnits("1", 6); since its aUSDC or you use ethers.utils.parseEther("1").

Also, you might want to remove the gasLimit and then the value should be estimatedGas not BigInt(3000000)

Olanetsoft commented 3 months ago

Take a look at this contract; https://github.com/axelarnetwork/axelar-examples/blob/main/examples/evm/call-contract-with-token/CallContractWithToken.sol

Lukols-Dev commented 3 months ago

then I am making changes, thank you I'll let you know if it worked

Lukols-Dev commented 3 months ago
  1. I changed the contract to the one you sent and once again made it deploy to Sepolia and mumbai and I received two addresses after deploy: Sepolia: 0xe4d72642C95a93025dA2cc4ad10208697FCAb243 Mumbai: 0xF98Abec00254BCf19Ff2815Ed9c46939F18c09dC

import { ethers } from "hardhat";

//Deploy for Poligon and Sepolia

async function main() { const [deployer] = await ethers.getSigners();

console.log("Deploying contracts with the account:", deployer.address);

const Contract = await ethers.getContractFactory("CallContractWithToken"); const contract = await Contract.deploy( "0xBF62ef1486468a6bd26Dd669C06db43dEd5B849B", "0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6", ); //From here https://docs.axelar.dev/resources/contract-addresses/testnet

console.log("Contract address:", contract.address); }

main() .then(() => process.exit(0)) .catch((error) => { console.error(error); process.exit(1); });

Lukols-Dev commented 3 months ago
  1. I called up the script in the corrected form, filled in the new addresses I received and got the error:

Estimate gas: 104766895062823 Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (reason="execution reverted: arithmetic underflow or overflow", method="estimateGas", transaction={"from":"0x1e147BA822892748ED2A8952C582e4da4A3200ff","to":"0xe4d72642C95a93025dA2cc4ad10208697FCAb243","value":{"type":"BigNumber","hex":"0x5f48f1907f27"},"data":"0xfbd9497b00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000000000000007506f6c79676f6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a3078463938416265633030323534424366313946663238313545643963343639333946313863303964430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001e147ba822892748ed2a8952c582e4da4a3200ff00000000000000000000000000000000000000000000000000000000000000056155534443000000000000000000000000000000000000000000000000000000","accessList":null}, error={"name":"ProviderError","_stack":"ProviderError: execution reverted: arithmetic underflow or overflow\n at HttpProvider.request (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/hardhat/src/internal/core/providers/http.ts:90:21)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async EthersProviderWrapper.send (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)","code":3,"_isProviderError":true,"data":"0x4e487b710000000000000000000000000000000000000000000000000000000000000011"}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.7.2) at Logger.makeError (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@ethersproject/logger/src.ts/index.ts:269:28) at Logger.throwError (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@ethersproject/logger/src.ts/index.ts:281:20) at checkError (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:78:20) at EthersProviderWrapper. (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:642:20) at step (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23) at Object.throw (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53) at rejected (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65) at processTicksAndRejections (node:internal/process/task_queues:95:5) { reason: 'execution reverted: arithmetic underflow or overflow', code: 'UNPREDICTABLE_GAS_LIMIT', method: 'estimateGas', transaction: { from: '0x1e147BA822892748ED2A8952C582e4da4A3200ff', to: '0xe4d72642C95a93025dA2cc4ad10208697FCAb243', value: BigNumber { value: "104766895062823" }, data: '0xfbd9497b00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000000000000007506f6c79676f6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a3078463938416265633030323534424366313946663238313545643963343639333946313863303964430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001e147ba822892748ed2a8952c582e4da4a3200ff00000000000000000000000000000000000000000000000000000000000000056155534443000000000000000000000000000000000000000000000000000000', accessList: null }, error: ProviderError: execution reverted: arithmetic underflow or overflow at HttpProvider.request (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/hardhat/src/internal/core/providers/http.ts:90:21) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async EthersProviderWrapper.send (/Users/lukols/Documents/Programowanie/Blockchain/hardhat-version/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20) }

Lukols-Dev commented 3 months ago
  1. My script looks like this: import { ethers } from "hardhat"; import { AxelarQueryAPI, Environment, EvmChain, GasToken } from "@axelar-network/axelarjs-sdk";

async function main() { const destinationAdress = "0xF98Abec00254BCf19Ff2815Ed9c46939F18c09dC"; //deployed contract in Mumbai const destinationChain = "Polygon"; // chain name const adressess = ["0x1e147BA822892748ED2A8952C582e4da4A3200ff"]; //wallet address const symbol = "aUSDC"; // token symbol const amount = ethers.utils.parseUnits("1", 6);

// Get contract const contract = await ethers.getContractAt( "CallContractWithToken", "0xe4d72642C95a93025dA2cc4ad10208697FCAb243", //Deployed contract in Sepolia );

// Estimate Gas const api = new AxelarQueryAPI({ environment: Environment.TESTNET });

const estimatedGas = await api.estimateGasFee( "ethereum-sepolia", EvmChain.POLYGON, GasToken.ETH, 700000, 2, );

console.log("Estimate gas: ", estimatedGas);

const sendTx = await contract.sendToMany( destinationChain, destinationAdress, adressess, symbol, amount, { value: estimatedGas.toString(), }, ); await sendTx.wait();

console.log(Initialize: ${sendTx.hash}); }

main().catch((error) => { console.error(error); process.exit(1); });

Lukols-Dev commented 3 months ago

On sepolia I don't have aUSDC, where can I get it, there are no assets in the testnet documentation

Olanetsoft commented 3 months ago

You can get it on our discord in the faucet channel. By specifying !faucet <network> <your address>.

Lukols-Dev commented 3 months ago

ok, I take but where to find the address of the aUSDC token for testnet, there were videos on youtube that for testnet assets are there, in fact there is no such data in the Axelar documentation?

Olanetsoft commented 3 months ago

Hey @Lukols-Dev, you can find the aUSDC address for testnet here: https://docs.axelar.dev/resources/contract-addresses/testnet#assets