基于区块链的毕业设计Araswap – 阿拉斯瓦普

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Araswap – 阿拉斯瓦普 是一篇很好的国外资料

Araswap

Simple Aragon app for swapping tokens and ETH.

This is only an experiment, intended to be used as a tutorial to learn developing Aragon apps. Don’t use this on mainnet!!!

Based on this Solidity version of Uniswap contracts.

Running your app

To run the app in a browser with frontend and contract hot-reloading, simply run npm start.

npm Scripts

  • postinstall: Runs after installing dependencies.
  • build-app: Installs front end project (app/) dependencies.
  • start Runs your app inside a DAO.
  • compile: Compiles the smart contracts.
  • test: Runs tests for the contracts.
  • publish:major: Releases a major version to aragonPM.
  • publish:minor: Releases a minor version to aragonPM.
  • publish:patch: Releases a patch version to aragonPM.

Tutorial

Step 0

git checkout step_0 

This is just the simple Counter app that comes bundled with create-aragon-app command.

You can try modifying either the frontend or the contracts and see the hot reloading in action.

Step 1

git checkout step_1 

You can also run

git diff step_0..step_1 

to see the relevant code for this first step.

With this step you have an upgradable version of Uniswap, embedded in a DAO with a Token Manager and a Voting app, that will govern this upgradeability. Liquidity tokens of the exchange app are still independent, and fees are fixed (hardcoded).

Step 2

git checkout step_2 

As in the previous step, you can run

git diff step_1..step_2 

to see what has changed.

Here we go one step beyond and the liquidity token of the Araswap serves as native token of the DAO. This means that the (only) way to become member of the DAO is by providing liquity to the exchange, and the more liquidity you provide, the more power you will have in the DAO.

There’s a new role, assigned to Voting app, which in turn relies on the Token Manager and therefore in the liquidity providers, that allows to change the fees paid on exchanging.

Test

Before testing, it may be a good idea to check scripts/buidler-hooks.js file, where all the buidler magic for setting the environment up happens.

Open a console with npx buidler console and try the following commands to test all those things explained above:

const accounts = await web3.eth.getAccounts()  web3.utils.fromWei(await web3.eth.getBalance(accounts[0]))  // minime is the liquidity token and the token of the DAO const MiniMeToken = await artifacts.require('MiniMeToken') const minime = await MiniMeToken.at('0xdc05EFc3029024068FCc86f05323411f14D69280')  // ANT is the token exchanged const ant = await MiniMeToken.at('0xf1f8AAc64036cdd399886b1C157B7e3b361093F3') const ant = await MiniMeToken.at('0x9D6F6d86B81289e40e07fCdA805C06F6E9B8f629')  // initial token supplies web3.utils.fromWei(await minime.totalSupply()) web3.utils.fromWei(await ant.totalSupply())  // initial balances web3.utils.fromWei(await minime.balanceOf(accounts[0])) web3.utils.fromWei(await ant.balanceOf(accounts[0]))  // our exchange app const Araswap = await artifacts.require('Araswap') const araswap = await Araswap.at('0x8f1cf28DCD72f5CF75091E61BF99f7Ac2edb9DAC') // with its balances web3.utils.fromWei(await ant.balanceOf(araswap.address)) web3.utils.fromWei(await web3.eth.getBalance(araswap.address))  // first approve the exchange token to the exchange app await ant.approve(araswap.address, await ant.balanceOf(accounts[0]), { from: accounts[0] }) await ant.approve(araswap.address, await ant.balanceOf(accounts[1]), { from: accounts[1] }) await ant.approve(araswap.address, await ant.balanceOf(accounts[2]), { from: accounts[2] })  // add liquidity, from different accounts and amounts await araswap.addLiquidity(1, web3.utils.toWei('10'), 2123456789, { value: web3.utils.toWei('1') }) await araswap.addLiquidity(1, web3.utils.toWei('100'), 2123456789, { value: web3.utils.toWei('1'), from: accounts[1] }) await araswap.addLiquidity(1, web3.utils.toWei('100'), 2123456789, { value: web3.utils.toWei('2.2'), from: accounts[2] })  // add liqidity with a simple transaction (that hits the payable fallback) web3.utils.fromWei(await ant.balanceOf(accounts[3])) web3.utils.fromWei(await web3.eth.getBalance(accounts[3])) await araswap.sendTransaction({ value: web3.utils.toWei('0.5'), from: accounts[3] }) web3.utils.fromWei(await ant.balanceOf(accounts[3])) web3.utils.fromWei(await web3.eth.getBalance(accounts[3])) 

Any time you add liquidity, make sure to check on the frontend how new tokens are minted on the Token Manager.


Araswap

简单的阿拉贡应用程序交换代币和以太币。

⚠ 这只是一个实验,旨在作为学习开发阿拉贡应用程序的教程。不要在mainnet上使用这个!!!

基于此版本的Uniswap合同。

运行应用程序

要在带有前端和合同热加载的浏览器中运行应用程序,只需运行npm start。

npm脚本

  • 安装后:安装依赖项后运行。构建应用程序:安装前端项目(app/)依赖项。
  • 开始在DAO中运行应用程序。编译:编译智能合约。
  • 测试:为合同运行测试。
  • 发布:专业:向aragonPM发布主要版本。
  • 发布:次要:将次要版本发布到aragonPM。
  • 发布:修补程序:向aragonPM发布修补程序版本。你知道吗
  • publish:minor: Releases a minor version to aragonPM.
  • publish:patch: Releases a patch version to aragonPM.

教程

步骤0

git checkout step_0 

这只是与create aragon app命令捆绑在一起的简单计数器应用程序。

您可以尝试修改前端或契约,并查看热重新加载的操作。

步骤1

git checkout step_1 

您也可以运行

git diff step_0..step_1 

查看第一步的相关代码。

通过此步骤,您将拥有一个Uniswap的可升级版本,该版本嵌入到带有令牌管理器和投票应用程序的DAO中,将控制此可升级性。exchange应用程序的流动性代币仍然是独立的,并且费用是固定的(硬编码)。

步骤2

git checkout step_2 

与上一步一样,您可以运行

git diff step_1..step_2 

查看发生了什么变化。

在这里,我们更进一步,Araswap的流动性令牌充当DAO的本机令牌。这意味着成为DAO成员的唯一途径是向交易所提供流动性,你提供的流动性越多,你在DAO中拥有的权力就越大。

有一个新的角色,分配给投票应用程序,它反过来依赖于代币管理器,因此在流动性提供者中,允许更改交换时支付的费用。

测试

在测试之前,最好检查脚本/buidler-钩子.js文件,所有用于设置环境的buidler魔法都在这里发生。

使用npx buidler console打开一个控制台,并尝试以下命令来测试上面解释的所有内容:

const accounts = await web3.eth.getAccounts()  web3.utils.fromWei(await web3.eth.getBalance(accounts[0]))  // minime is the liquidity token and the token of the DAO const MiniMeToken = await artifacts.require('MiniMeToken') const minime = await MiniMeToken.at('0xdc05EFc3029024068FCc86f05323411f14D69280')  // ANT is the token exchanged const ant = await MiniMeToken.at('0xf1f8AAc64036cdd399886b1C157B7e3b361093F3') const ant = await MiniMeToken.at('0x9D6F6d86B81289e40e07fCdA805C06F6E9B8f629')  // initial token supplies web3.utils.fromWei(await minime.totalSupply()) web3.utils.fromWei(await ant.totalSupply())  // initial balances web3.utils.fromWei(await minime.balanceOf(accounts[0])) web3.utils.fromWei(await ant.balanceOf(accounts[0]))  // our exchange app const Araswap = await artifacts.require('Araswap') const araswap = await Araswap.at('0x8f1cf28DCD72f5CF75091E61BF99f7Ac2edb9DAC') // with its balances web3.utils.fromWei(await ant.balanceOf(araswap.address)) web3.utils.fromWei(await web3.eth.getBalance(araswap.address))  // first approve the exchange token to the exchange app await ant.approve(araswap.address, await ant.balanceOf(accounts[0]), { from: accounts[0] }) await ant.approve(araswap.address, await ant.balanceOf(accounts[1]), { from: accounts[1] }) await ant.approve(araswap.address, await ant.balanceOf(accounts[2]), { from: accounts[2] })  // add liquidity, from different accounts and amounts await araswap.addLiquidity(1, web3.utils.toWei('10'), 2123456789, { value: web3.utils.toWei('1') }) await araswap.addLiquidity(1, web3.utils.toWei('100'), 2123456789, { value: web3.utils.toWei('1'), from: accounts[1] }) await araswap.addLiquidity(1, web3.utils.toWei('100'), 2123456789, { value: web3.utils.toWei('2.2'), from: accounts[2] })  // add liqidity with a simple transaction (that hits the payable fallback) web3.utils.fromWei(await ant.balanceOf(accounts[3])) web3.utils.fromWei(await web3.eth.getBalance(accounts[3])) await araswap.sendTransaction({ value: web3.utils.toWei('0.5'), from: accounts[3] }) web3.utils.fromWei(await ant.balanceOf(accounts[3])) web3.utils.fromWei(await web3.eth.getBalance(accounts[3])) 

任何时候添加流动性时,请确保在前端检查如何在令牌管理器上生成新令牌。

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/21269.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计Araswap – 阿拉斯瓦普

提供最优质的资源集合

立即查看 了解详情