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
Node.js how to take a class method argument and use it to call "this.argument"

hey guys i have a question. So i have a class in nodejs and in the constructor i initialiuse a few smart contracts from uniswap. However i am making a function that takes in as a parameter on one the smart contratcs that i initialise in the constructor. however when I i try to call the method and pass in the uniswapFactoryContract as an arg called "echangeName", node takes this.exchangeName asit is, but instead of taking exchangeName as the arg i pass in it takes it as this.echangeName not this.TheNameOfTheArgIPassIn. My code is below could anyone help me or provide another way

module.exports =class Registry {

constructor() {

    //default token addresses
    this.DAI = "0x6b175474e89094c44da98b954eedeac495271d0f";
    this.WETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";

    //default provided exhange addressses
    this.UniswapFactoryAddress = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";
    this.UniswapRouterAddress = "0xf164fC0Ec4E93095b804a4795bBe1e041497b92a";

    

}

//when i call this in index.js i specifcy the uniswapFactoryaddress as the exchange name paramrer
async getTokenPairSddress(addressToken0, addressToken1,  exchangeName) {

   
    //this line throws the error it thinks i want this.echange name instead of
    //this.uniswapFactoryContract
    const pairAddress = await this.exchangeName.methods.getPair(addressToken0, addressToken1).call();

    return pairAddress;

}

}

about 4 years ago · Juan Pablo Isaza
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