dexfinal's People
Forkers
vargosky abiblock ponlex vuflysocial mighty10 vordium danich00 ralphskaf okpainmo second15 prafulljosh hatterdev aliaksandrradzko danutz605 7711227 alienneila9 useitwise roliveira3891 cryptoqueen23 fileype dippydoge bicabo98 hiddenfeet nguyensythinhk7 amakarem 6ix78 abuhaneeph christinedd2 taiwotimman sponsorcoinadmin krbappy00 thatzprem amon-s sighttviewliu genius70 ibold-dev barzoid1 rhayar-dr chris2590 pgill0630 joshephan naino142 arpit3210 manoj652 spreegore vitammiin elsenadorisback beginner-projects kryptonode rzero0101 toodlesminer ahmedchaudhry-1 awaisahmadfg kingdotnet wangai003 venkatsammm aduwoayooluwa ayadagdexfinal'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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.