Aragox OSX - Creating a Project for Working with Aragon. Part 1
In this article, we will cover the creation of a basic project for interacting with the Aragon ecosystem. We will go through installing the necessary dependencies, setting up the environment, and adding libraries for working with Aragon OSx.
1. Creating a Project and Installing Dependencies
First, let's ensure that we have the necessary dependencies installed:
- NodeJS (version >= 18) - Used to run JavaScript code outside the browser and is the foundation for many development tools.
- Yarn - A package manager that allows quick installation and management of project dependencies.
To check if the dependencies are installed, run the following commands:
node -v # Check Node.js version
yarn -v # Check Yarn version
If any dependency is missing, install it using the following command:
npm install -g yarn # Install Yarn
Now we can create a new project and install the required packages. It is important to note that Aragon is constantly being updated, so always check the latest package versions in the documentation.
Installing Hardhat
Hardhat is a framework for working with blockchains and smart contracts, allowing for easy testing and deployment.
Install Hardhat with the following command:
yarn add hardhat
Creating a Hardhat Project
Run the following command to initialize a project:
npx hardhat
Next, choose the project type and install the necessary dependencies:
- Select Create a basic sample project.
- Specify the project directory.
- Confirm the creation of hardhat.config.ts.
2. Configuring Access and Services
To interact with the Ethereum network, we need Infura—an RPC service that allows communication with the blockchain without running our own node.
Registering and Configuring Infura
- Go to Infura and sign up.
- Create a new project in the Infura Dashboard.
- Enable support for the Ethereum Sepolia test network.
Adding API Keys to the .env File
To securely store secret keys, create a .env file in the project's root directory and add the necessary environment variables.
Install the dotenv package:
yarn add dotenv
Add the following variables to the .env file:
INFURA_KEY=your_infura_api_key
PRIVATE_KEY=your_wallet_private_key
3. Configuring the Network
Now we will configure Hardhat to work with the Ethereum Sepolia test network.
Open the hardhat.config.ts file and add network support. In the networks section, we define the list of networks Hardhat can connect to. Each network requires an RPC URL and accounts for signing transactions.
- url: This is the endpoint for the Ethereum node. In this case, we use Infura, which allows us to connect to the network without running our own node.
- accounts: An array containing the private key used to sign transactions. We use the .env file to store this key securely.
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import * as dotenv from "dotenv";
dotenv.config();
const config: HardhatUserConfig = {
solidity: {
version: "0.8.19",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
networks: {
sepolia: {
url: `https://sepolia.infura.io/v3/${process.env.INFURA_KEY}`,
accounts: [process.env.PRIVATE_KEY!],
},
}
};
export default config;
4. Installing Aragon Packages
To work with Aragon, we need to install the following packages
yarn add @aragon/osx
This package contains the core libraries for working with Aragon OSx
yarn add @aragon/osx-artifacts
This package contains artifacts used for compiling smart contracts
yarn add @aragon/osx-commons-configs
Includes common configurations necessary for interacting with Aragon
yarn add @aragon/osx-ethers
Adds Ethereum API support through the Ethers.js library.
GitHub Repo
https://github.com/Mirko-Solutions/aragon2-examples/tree/main
Congratulations! 🎉 We have prepared a project for working with Aragon. In the next article, we will take a closer look at each of the installed packages and their use.
