Local Environment Setup

This guide walks through setting up a local development environment for VinuSwap.

Prerequisites

  • Node.js 16.x or higher

  • npm or yarn

  • Git

Clone the Repository

git clone https://github.com/VinuChain/VinuSwap-VinuChain.git
cd VinuSwap-VinuChain

Install Dependencies

npm install

This installs:

  • Hardhat development framework

  • Solidity compiler

  • TypeScript and type generators

  • Testing utilities

Compile Contracts

This generates:

  • Compiled artifacts in artifacts/

  • TypeChain type definitions in typechain-types/

Run Tests

Or run specific tests:

Start Local Network

This starts a local Hardhat node with:

  • 2000 test accounts with 10,000 VC each

  • Block time: instant

  • Chain ID: 31337

Deploy to Local Network

In a new terminal:

Project Structure

Hardhat Configuration

The hardhat.config.ts includes:

Environment Variables

Create a .env file:

TypeScript SDK Setup

The SDK is in the sdk/ directory:

Development Workflow

1. Make Contract Changes

Edit contracts in contracts/ directory.

2. Compile

3. Run Affected Tests

4. Run Full Test Suite

5. Deploy to Local Network

Useful Commands

Command
Description

npx hardhat compile

Compile contracts

npm run test

Run all tests

npx hardhat node

Start local node

npx hardhat clean

Clear artifacts

npx hardhat size-contracts

Check contract sizes

Common Issues

Compilation Errors

If you see "Contract code size exceeds limit":

  1. Check hardhat.config.ts for optimizer settings

  2. Ensure runs is set to 1 for large contracts

  3. Consider splitting functionality

Test Timeouts

Increase Mocha timeout in hardhat.config.ts:

TypeChain Issues

Regenerate types:

IDE Setup

VS Code

Recommended extensions:

  • Solidity (Juan Blanco)

  • Hardhat Solidity

  • ESLint

  • Prettier

Settings (.vscode/settings.json):

Next Steps

Last updated