Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!