Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
Passing a Smart Contract Function Parameter Derived from a Struct to Its Interaction Script

I'm trying to interact with a contract I just deployed with a JavaScript file on HardHat. However, I'm getting an error; I know why it's being caused, but I don't know how to fix it. In my contract I have a struct defined as FlashParams, and I have a function that uses it as a parameter as seen here (it's only part of my code since I know the rest of it isn't causing any issues):

//fee1 is the fee of the pool from the initial borrow
//fee2 is the fee of the first pool to arb from
//fee3 is the fee of the second pool to arb from
struct FlashParams {
    address token0;
    address token1;
    uint24 fee1;
    uint256 amount0;
    uint256 amount1;
    uint24 fee2;
    uint24 fee3;
}
// fee2 and fee3 are the two other fees associated with the two other pools of token0 and token1
struct FlashCallbackData {
    uint256 amount0;
    uint256 amount1;
    address payer;
    PoolAddress.PoolKey poolKey;
    uint24 poolFee2;
    uint24 poolFee3;
}


/// @param params The parameters necessary for flash and the callback, passed in as FlashParams
/// @notice Calls the pools flash function with data needed in `uniswapV3FlashCallback`
function initFlash(FlashParams memory params) external onlyOwner {
    PoolAddress.PoolKey memory poolKey =
        PoolAddress.PoolKey({token0: params.token0, token1: params.token1, fee: params.fee1});
    IUniswapV3Pool pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));

In my JS file I'm trying to pass the parameter from the contract as an argument in .initFlash(), but I don't know how to. Here's my JS file:

async function main() {
  
  
  const address = '0x90A39BaC0D3A796b52f0394b9A97897d8F26eB1c8';
  const PairFlash = await ethers.getContractFactory('PairFlash');
  const pairflash = await PairFlash.attach(address);
  
  

  const value = await pairflash.initFlash();
}

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

And here is the error:

Error: missing argument: passed to contract (count=0, expectedCount=1, code=MISSING_ARGUMENT, version=contracts/5.5.0)
reason: 'missing argument: passed to contract',
  code: 'MISSING_ARGUMENT',
  count: 0,
  expectedCount: 1

Does anybody know how to fix this? Thank you!

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I figured it out. The inputs for the JS file should be an a array format because this is the equivalent of a struct in solidity.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda