Giter VIP home page Giter VIP logo

dexfinal's People

Contributors

iamjaysway avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dexfinal's Issues

could not fetch TokenPricedata using API

I've been following the youtube tutorial and got stuck when implementing backend token price data in the console. I could not find what I did wrong.Do tell me what I need to change.

const express = require("express");
const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/evm-utils");
const app = express();
const cors = require("cors");
require("dotenv").config();
const port = 3001;

app.use(cors());
app.use(express.json());

app.get("./tokenPrice", async (req, res) => {
  const { query } = req;

  const responseOne = await Moralis.EvmApi.token.getTokenPrice({
    address: query.addressOne,
  });

  const responseTwo = await Moralis.EvmApi.token.getTokenPrice({
    address: query.addressTwo,
  });

  console.log(responseOne.raw);
  console.log(responseTwo.raw);

  return res.status(200).json({});
});

Moralis.start({
  apiKey: process.env.MORALIS_KEY,
}).then(() => {
  app.listen(port, () => {
    console.log(`Listening for API Calls`);
  });
});

// const runApp = async () => {
//   await Moralis.start({
//     apiKey: process.env.MORALIS_KEY,
//     // ...and any other configuration
//   });

//   const address = "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599";

//   const chain = EvmChain.ETHEREUM;

//   const response = await Moralis.EvmApi.token.getTokenPrice({
//     address,
//     chain,
//   });

//   console.log(response.toJSON());
// };

// runApp();

```

Sending allowance approval to axios 1inch router sends repeatedly

Any idea why the const allowance would send to my metamask wallet continuously? I have no useEffects, and exuecute the function on click the same as you do for swap function. It works properly on the swap function that I built with your help, but in the funciton below it is set up the same way, and practically breaks my browser within 10 seconds.

async function fetchDexBuy() {
var tokenAmount = () => {
if(checked === "eth") {
return String(amount *(baseLine.padEnd(18+baseLine.length, '0')))
}else if (checked === "usd"){
return String((amount/cryptoDetails.price) * (baseLine.padEnd(18+ baseLine.length, '0'))) ;
} else {
return String((amount * ethExRate) * (baseLine.padEnd(18+baseLine.length, "0")))
};
}
const allowance = await axios.get(https://api.1inch.io/v5.0/1/approve/allowance?tokenAddress=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&walletAddress=${address})

  if(allowance.data.allowance === "0"){
    const approve = await axios.get(`https://api.1inch.io/v5.0/1/approve/transaction?tokenAddress=${ethAddress}`)
    setTxDetails(approve.data)
    console.log("Not Approved")
    return 
  }
  const tx = await axios.get(
    `https://api.1inch.io/v5.0/1/swap?fromTokenAddress=${ethAddress}&toTokenAddress=${tokenObject.address}&amount=${tokenAmount()}&fromAddress=${address}&slippage=${slippage}&fee=1.25`
  )
  let decimals = Number(`1E${tokenObject.decimals}`)
  let tokenTwo = (Number(tx.data.toTokenAmount)/decimals).toFixed(2)
  console.log(tokenTwo);
  setTxDetails(tx.data.tx)
}

Additionally, I would like to start a DAO, and as I am planning on using your swap page on my site would like to give tokens to yourself or Moralis whomever claims the intellectual property. I have plans to get more developers involved at DEFIProtocol/deployed-gridlock. My site is https://gridlock.live.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.