Subscribe to 2-333.eth
Subscribe to 2-333.eth
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
ENGLISH:
1、Currently we setthe token allowance is set to the max amount. Change this to be safer so the user only approves just the amount needed.
In the trySwap function, I adjusted the "MAXApproval" parameter to the number of tokens entered by the user in the front-end, using the "sellAmount" parameter in swapPriceJSON
2、Show estimated gas in $
First get "gasPrice" by using "getGasPrice" in Ethers:
provider.getGasPrice()
Then use Chainlink to get the "latestRoundData" data of ETH, in which the "answer" is the real-time price of ETH:
const addr = "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e" const priceFeed = new ethers.Contract(addr, aggregatorV3InterfaceABI, provider) priceFeed.latestRoundData() .then((roundData) => { ETHprice = roundData.answer.toString()/10e7// Do something with roundData console.log("Latest price", ETHprice) })
Finally, multiply estimatedGas, gasPrice, and ETHprice to get the $ gasfee:
ethers.utils.formatEther(swapPriceJSON.estimatedGas)*gasPrice.toString()*ETHprice
After learning the basic syntax of js by myself, I successfully completed the transformation and upgrading of the basic code.
Answer ALL of these questions:
Who are you, and what is your software development background?
I'm axrid, I'm not a computer science major, I only know some basic Python and JS. I'm learning solidity now and want to work in web3 related work.
Why did you want to complete this lesson?
I taught myself the basic syntax of JS and wanted to consolidate what I learned in this lesson. So I built the code following the video tutorial and completed the challenge.
When did you complete the project?
I started the course on November 1 and finished it on November 6, with a total duration of about 5h.
What technologies did you use?
https://docs.alchemy.com/docs/how-to-build-a-token-swap-dapp-with-0x-api
I followed the official tutorials to learn, mainly using JS and the related APIs of Chainlink, 0x, and Alchemy.
What did you enjoy about the tutorial?
Through learning and modifying the code, I understood the relationship between the front-end modules. I also understand that front-end and Solidity are equally important in Blockchain development.
How do you think you can use this technology to build useful applications in the future? What are some specific example applications?
This is a tutorial about DEX, and to be honest, I'm not going to build a new DEX. in this lesson I learned to get token price through Chainink and interact with Blockchain through Ethers. I plan to make some JS scripts related to Blockchain.
Who would you recommend this project to?
A friend of mine who has learned JS, C++, Python, maybe he can master this lesson easily.
What is the Ethereum wallet address you would like to receive your PoK at?
My address (I may delete the wallet address from this post when I mint nft):
0xe62ef3e82127bb97e641b15e866798c827206762
My smart contract code:
I completed the following two challenges:
1、Currently we setthe token allowance is set to the max amount. Change this to be safer so the user only approves just the amount needed.
In the trySwap function, I adjusted the "MAXApproval" parameter to the number of tokens entered by the user in the front-end, using the "sellAmount" parameter in swapPriceJSON
2、Show estimated gas in $
First get "gasPrice" by using "getGasPrice" in Ethers:
provider.getGasPrice()
Then use Chainlink to get the "latestRoundData" data of ETH, in which the "answer" is the real-time price of ETH:
const addr = "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e" const priceFeed = new ethers.Contract(addr, aggregatorV3InterfaceABI, provider) priceFeed.latestRoundData() .then((roundData) => { ETHprice = roundData.answer.toString()/10e7// Do something with roundData console.log("Latest price", ETHprice) })
Finally, multiply estimatedGas, gasPrice, and ETHprice to get the $ gasfee:
ethers.utils.formatEther(swapPriceJSON.estimatedGas)*gasPrice.toString()*ETHprice

中文:
自学了js的基本语法后,顺利的完成了基础代码的改造提升。
answer ALL of these questions:
Who are you, and what is your software development background?
我是axrid,我不是计算机专业,只会一些基础的python和js。我现在正在学习solidity,想要从事web3相关的工作。
Why did you want to complete this lesson?
我自学了js的基本语法,想要在这一课里巩固所学内容。因此我按照视频教程搭建了code,并完成了挑战。
When did you complete the project?
我从11月1日开始学习,在11月6完成课程,总时长大概5h。
What technologies did you use?
https://docs.alchemy.com/docs/how-to-build-a-token-swap-dapp-with-0x-api
我跟随官方教程进行学习,主要使用javascript,以及chainlink, 0x, alchemy
What did you enjoy about the tutorial?
通过对代码的学习和修改,我理解了前端各个文件之间的关系。也明白了blockchain行业里,前端和solidity同样重要
How do you think you can use this technology to build useful applications in the future? What are some specific example applications?
这是一个关于DEX的教程,老实说,我不会去搭建一个新的DEX。在这一课我学会了通过chainink获取token price,通过ethers与blockchain交互。我打算做一些与blockchain相关的js脚本。
Who would you recommend this project to?
我的一位朋友,他学过js、c++、python,也许他可以很轻松的掌握这一课
What is the Ethereum wallet address you would like to receive your PoK at?
My smart contract code:
我完成了以下两个挑战
1、目前我们设置令牌限额设置为最大金额.更改此项以使其更安全,以便用户仅批准所需的金额。
{}在trySwap中,我把MAXApproval的参数调整为用户在前端中输入的token数量,借用了swapPriceJSON中的sellAmount参数
2、以 $ 为单位显示估计的气体
{}首先通过Ethers中的getGasPrice来获取gasPrice
provider.getGasPrice()
然后使用Chainlink来获取ETH的latestRoundData数据,里面的”answer”就是ETH的实时价格
const addr = "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e" const priceFeed = new ethers.Contract(addr, aggregatorV3InterfaceABI, provider) priceFeed.latestRoundData() .then((roundData) => { ETHprice = roundData.answer.toString()/10e7// Do something with roundData console.log("Latest price", ETHprice) })
最终将estimatedGas、gasPrice、ETHprice相乘,得到以美元计价的gasfee
ethers.utils.formatEther(swapPriceJSON.estimatedGas)*gasPrice.toString()*ETHprice
ENGLISH:
1、Currently we setthe token allowance is set to the max amount. Change this to be safer so the user only approves just the amount needed.
In the trySwap function, I adjusted the "MAXApproval" parameter to the number of tokens entered by the user in the front-end, using the "sellAmount" parameter in swapPriceJSON
2、Show estimated gas in $
First get "gasPrice" by using "getGasPrice" in Ethers:
provider.getGasPrice()
Then use Chainlink to get the "latestRoundData" data of ETH, in which the "answer" is the real-time price of ETH:
const addr = "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e" const priceFeed = new ethers.Contract(addr, aggregatorV3InterfaceABI, provider) priceFeed.latestRoundData() .then((roundData) => { ETHprice = roundData.answer.toString()/10e7// Do something with roundData console.log("Latest price", ETHprice) })
Finally, multiply estimatedGas, gasPrice, and ETHprice to get the $ gasfee:
ethers.utils.formatEther(swapPriceJSON.estimatedGas)*gasPrice.toString()*ETHprice
After learning the basic syntax of js by myself, I successfully completed the transformation and upgrading of the basic code.
Answer ALL of these questions:
Who are you, and what is your software development background?
I'm axrid, I'm not a computer science major, I only know some basic Python and JS. I'm learning solidity now and want to work in web3 related work.
Why did you want to complete this lesson?
I taught myself the basic syntax of JS and wanted to consolidate what I learned in this lesson. So I built the code following the video tutorial and completed the challenge.
When did you complete the project?
I started the course on November 1 and finished it on November 6, with a total duration of about 5h.
What technologies did you use?
https://docs.alchemy.com/docs/how-to-build-a-token-swap-dapp-with-0x-api
I followed the official tutorials to learn, mainly using JS and the related APIs of Chainlink, 0x, and Alchemy.
What did you enjoy about the tutorial?
Through learning and modifying the code, I understood the relationship between the front-end modules. I also understand that front-end and Solidity are equally important in Blockchain development.
How do you think you can use this technology to build useful applications in the future? What are some specific example applications?
This is a tutorial about DEX, and to be honest, I'm not going to build a new DEX. in this lesson I learned to get token price through Chainink and interact with Blockchain through Ethers. I plan to make some JS scripts related to Blockchain.
Who would you recommend this project to?
A friend of mine who has learned JS, C++, Python, maybe he can master this lesson easily.
What is the Ethereum wallet address you would like to receive your PoK at?
My address (I may delete the wallet address from this post when I mint nft):
0xe62ef3e82127bb97e641b15e866798c827206762
My smart contract code:
I completed the following two challenges:
1、Currently we setthe token allowance is set to the max amount. Change this to be safer so the user only approves just the amount needed.
In the trySwap function, I adjusted the "MAXApproval" parameter to the number of tokens entered by the user in the front-end, using the "sellAmount" parameter in swapPriceJSON
2、Show estimated gas in $
First get "gasPrice" by using "getGasPrice" in Ethers:
provider.getGasPrice()
Then use Chainlink to get the "latestRoundData" data of ETH, in which the "answer" is the real-time price of ETH:
const addr = "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e" const priceFeed = new ethers.Contract(addr, aggregatorV3InterfaceABI, provider) priceFeed.latestRoundData() .then((roundData) => { ETHprice = roundData.answer.toString()/10e7// Do something with roundData console.log("Latest price", ETHprice) })
Finally, multiply estimatedGas, gasPrice, and ETHprice to get the $ gasfee:
ethers.utils.formatEther(swapPriceJSON.estimatedGas)*gasPrice.toString()*ETHprice

中文:
自学了js的基本语法后,顺利的完成了基础代码的改造提升。
answer ALL of these questions:
Who are you, and what is your software development background?
我是axrid,我不是计算机专业,只会一些基础的python和js。我现在正在学习solidity,想要从事web3相关的工作。
Why did you want to complete this lesson?
我自学了js的基本语法,想要在这一课里巩固所学内容。因此我按照视频教程搭建了code,并完成了挑战。
When did you complete the project?
我从11月1日开始学习,在11月6完成课程,总时长大概5h。
What technologies did you use?
https://docs.alchemy.com/docs/how-to-build-a-token-swap-dapp-with-0x-api
我跟随官方教程进行学习,主要使用javascript,以及chainlink, 0x, alchemy
What did you enjoy about the tutorial?
通过对代码的学习和修改,我理解了前端各个文件之间的关系。也明白了blockchain行业里,前端和solidity同样重要
How do you think you can use this technology to build useful applications in the future? What are some specific example applications?
这是一个关于DEX的教程,老实说,我不会去搭建一个新的DEX。在这一课我学会了通过chainink获取token price,通过ethers与blockchain交互。我打算做一些与blockchain相关的js脚本。
Who would you recommend this project to?
我的一位朋友,他学过js、c++、python,也许他可以很轻松的掌握这一课
What is the Ethereum wallet address you would like to receive your PoK at?
My smart contract code:
我完成了以下两个挑战
1、目前我们设置令牌限额设置为最大金额.更改此项以使其更安全,以便用户仅批准所需的金额。
{}在trySwap中,我把MAXApproval的参数调整为用户在前端中输入的token数量,借用了swapPriceJSON中的sellAmount参数
2、以 $ 为单位显示估计的气体
{}首先通过Ethers中的getGasPrice来获取gasPrice
provider.getGasPrice()
然后使用Chainlink来获取ETH的latestRoundData数据,里面的”answer”就是ETH的实时价格
const addr = "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e" const priceFeed = new ethers.Contract(addr, aggregatorV3InterfaceABI, provider) priceFeed.latestRoundData() .then((roundData) => { ETHprice = roundData.answer.toString()/10e7// Do something with roundData console.log("Latest price", ETHprice) })
最终将estimatedGas、gasPrice、ETHprice相乘,得到以美元计价的gasfee
ethers.utils.formatEther(swapPriceJSON.estimatedGas)*gasPrice.toString()*ETHprice
No activity yet