From 9169e0db62dbfe8122de848ae0c295ac7f683af9 Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 13:46:48 +0100 Subject: [PATCH] Add notes about how to use NPM package to import contract or artifacts --- README.md | 31 +++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aba2356e..739ef23c 100644 --- a/README.md +++ b/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`. diff --git a/package.json b/package.json index ea016bca..d5cd3e16 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aave/protocol-v2", - "version": "1.0.0", + "version": "1.0.1", "description": "Aave Protocol V2 smart contracts", "files": [ "contracts",