mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Add notes about how to use NPM package to import contract or artifacts
This commit is contained in:
parent
e84ab7cf03
commit
9169e0db62
31
README.md
31
README.md
|
@ -39,6 +39,37 @@ A more detailed and technical description of the protocol can be found in this r
|
|||
|
||||
You can join at the [Discord](http://aave.com/discord) channel or at the [Governance Forum](https://governance.aave.com/) for asking questions about the protocol or talk about Aave with other peers.
|
||||
|
||||
## Getting Started
|
||||
|
||||
You can install `@aave/protocol-v2` as an NPM package in your Hardhat, Buidler or Truffle project to import the contracts and interfaces:
|
||||
|
||||
`npm install @aave/protocol-v2`
|
||||
|
||||
Import at Solidity files:
|
||||
|
||||
```
|
||||
import {ILendingPool} from "@aave/protocol-v2/contracts/interfaces/ILendingPool.sol";
|
||||
|
||||
contract Misc {
|
||||
|
||||
function deposit(address pool, address token, address user, uint256 amount) {
|
||||
ILendingPool(pool).deposit(token, amount, user, '0');
|
||||
{...}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The JSON artifacts with the ABI and Bytecode are also included into the bundled NPM package at `artifacts/` directory.
|
||||
|
||||
Import JSON file via Node JS `require`:
|
||||
|
||||
```
|
||||
const LendingPoolV2Artifact = require('@aave/protocol-v2/artifacts/contracts/protocol/lendingpool/LendingPool.sol/LendingPool.json');
|
||||
|
||||
// Log the ABI into console
|
||||
console.log(LendingPoolV2Artifact.abi)
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
The repository uses Docker Compose to manage sensitive keys and load the configuration. Prior any action like test or deploy, you must run `docker-compose up` to start the `contracts-env` container, and then connect to the container console via `docker-compose exec contracts-env bash`.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@aave/protocol-v2",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Aave Protocol V2 smart contracts",
|
||||
"files": [
|
||||
"contracts",
|
||||
|
|
Loading…
Reference in New Issue
Block a user