aave_brownie_py – 阿维·布朗尼·皮区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,aave_brownie_py – 阿维·布朗尼·皮区块链毕设代写 是一篇很好的国外资料

aave_brownie_py - 阿维·布朗尼·皮 aave_brownie_py - 阿维·布朗尼·皮

aave_brownie_py

Put down collateral, Borrow, and repay a loan from Aave! Use this to short assets and accrue interest.

You can see a web3 version of this here.

In our aave_borrow.py script, we do the following:

  1. Approve our ETH to be swapped for WETH
  2. Swap an amount of ETH for WETH
  3. Using deposit_to_aave we deposit the WETH as collateral
  4. We use that collateral to borrow LINK with borrow_erc20
  5. Then, we pay it back!
  6. We can view the txs on etherscan to see what’s going on under the hood.

Setup

You’ll need python installed.

pip install -r requirements.txt 

Or, if you run into issues use pipx:

pip install --user pipx pipx ensurepath # restart your terminal pipx install eth-brownie

You’ll need the following environment variables. You can set them all in your .env file:

export WEB3_INFURA_PROJECT_ID=YourProjectID export PRIVATE_KEY="0xasdfasdfasdfasd..." 
  • PRIVATE_KEY: Your Private Key from your Wallet. *Note: If using metamask, you’ll have to add a 0x to the start of your private key.
  • WEB3_INFURA_PROJECT_ID: Your connection to the blockchain. You can get a URL from a service like Infura]. Right now it is hard coded to work with infura, but you can modify it however you want using brownie networks modify.

Run source .env

This doesn’t auto-pull in your .env file at the start, so you have to set your environment variables at the start.

And last, be sure to check the aave_dai_token if you’re using a testnet DAI token. Aave sometimes changes the token they use on testnet to keep liquidity, please check here for reference. Also, feel free to check the Aave docs as well, to learn more about the tools we are using.

Quickstart – kovan

  1. Get some kovan ETH

  2. Get some WETH

brownie run scripts/get_weth.py --network kovan 
  1. Run the script!
brownie run scripts/aave_borrow.py --network kovan 

Quickstart – mainnet-fork

Optional for running locally: If you want to run locally, you can install ganache-cli and yarn. Here is where you can install yarn.

yarn global add ganache-cli 

Then, you can run ganache-cli --fork YOUR_INFURA_URL_HERE, or just brownie run <YOUR_SCRIPT> --network mainnet-fork

  1. Get some WETH, borrow, and repay!
brownie run scripts/aave_borrow.py 

aave_brownie_py - 阿维·布朗尼·皮aave_brownie_py - 阿维·布朗尼·皮

aave_brownie_py

放下抵押品,向Aave借款并偿还贷款!用它做空资产和累积利息

你可以在这里看到这个的web3版本

在aaveu borrow.py脚本中,我们执行以下操作:

  1. 批准我们的ETH被换成WETH
  2. 用存款换成WETH
  3. 我们将WETH作为抵押品进行存款与借阅链接的借阅抵押品然后,我们将偿还
  4. 我们可以在etherscan上查看txs,看看引擎盖下发生了什么
  5. 私钥:钱包中的私钥*注意:如果使用元掩码,则必须在私钥的开头添加0x
  6. WEB3u INFURAu项目ID:您与区块链blockchain的连接。您可以从类似Infura]的服务获取URL。现在,使用infura是很难编码的,但是您可以使用brownie networks修改它

运行source.env

Quickstart-kovan

Quickstart-mainnet fork

您需要安装python

pip install -r requirements.txt 

或者,如果遇到问题,请使用pipx:

pip install --user pipx pipx ensurepath # restart your terminal pipx install eth-brownie

您将需要以下环境变量。您可以在.env文件中设置它们:

export WEB3_INFURA_PROJECT_ID=YourProjectID export PRIVATE_KEY="0xasdfasdfasdfasd..." 
  • 拿些kovan ETH
  • 拿些WETH

运行source.env

这不会在开始时自动拉入.env文件,因此您必须在开始时设置环境变量

最后,如果您使用的是testnet dai令牌,请确保检查aave_dai_令牌。Aave有时会更改他们在testnet上使用的令牌以保持流动性,请检查此处以供参考。另外,请随时查看Aave文档,以了解更多有关我们正在使用的工具的信息

Quickstart-kovan

  1. 运行脚本
  2. 获取一些WETH

brownie run scripts/get_weth.py --network kovan 
  1. Run the script!
brownie run scripts/aave_borrow.py --network kovan 

Quickstart – mainnet-fork

本地运行可选:如果您想在本地运行,可以安装ganache cli和Thread。这里是你可以安装纱线的地方

yarn global add ganache-cli 

然后,您可以运行ganache cli——在这里输入您的URL,或者只运行brownie-run&lt;您的_脚本&gt–network mainnet fork

  1. Get some WETH, borrow, and repay!
brownie run scripts/aave_borrow.py 

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

www.interchains.cc

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

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

提供最优质的资源集合

立即查看 了解详情