Add notes about how to use NPM package to import contract or artifacts

This commit is contained in:
David Racero 2021-01-26 13:46:48 +01:00
parent e84ab7cf03
commit 9169e0db62
2 changed files with 32 additions and 1 deletions

View File

@ -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. 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 ## 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`. 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`.

View File

@ -1,6 +1,6 @@
{ {
"name": "@aave/protocol-v2", "name": "@aave/protocol-v2",
"version": "1.0.0", "version": "1.0.1",
"description": "Aave Protocol V2 smart contracts", "description": "Aave Protocol V2 smart contracts",
"files": [ "files": [
"contracts", "contracts",