Back End Installation
This section walks you through setting up the backend for ArtVault, which contains the smart contracts and blockchain configuration.
App Structure
Each part plays a specific role:
- contracts/: Contains the Smart Contracts, the core logic for the NFTs.
- migrations/: Defines how contracts are deployed on networks.
- truffle-config.js: Specifies networks (like Ganache) and compiler version
Important: You can skip this section and use our Deployment playround directly instead of manual installation Visit Deployment Playground
1. Install Dependencies
inside the root of /backend directory, run the following command to install the required packages:
2. Modify truffle-config.js
Open truffle-config.js and ensure the following lines are present:
3. Deployment Script Configuration
Before running the contract deployment script, you need to manually update two key configuration values at 2_node_deploy_contracts.js:
1. privateKey (🔑 Your Wallet's Private Key)
This is the private key of the Ethereum account that will deploy the contracts.
⚠️ Warning: Never share your private key publicly. Make sure it's stored securely. In production, consider using environment variables or secret management tools instead of hardcoding.
2. commission (💸 Marketplace Fee)
This value represents the commission percentage that the marketplace contract will take from each transaction.
-
You can change this to any number (e.g. 5 means 5%)
-
It will be passed to the
NFTMarketplacecontract constructor during deployment
Example (Updated)
4. Deploy Smart Contracts
If you want to test the app locally before deploying to a mainnet or a testnet, you can use Ganache. Follow these steps:
- Open Ganache and create a new workspace.
- Make sure the workspace is running on port
8545. - Import acounts from Ganache to your Crypto wallet.
- In the
/backenddirectory of the project, run the following command to deploy the contracts:
If you want to run the app on a mainnet or a testnet. Follow these steps:
- Open
truffle-config.jsand search for your desired Network. - If you don't find it, you can add it as following.
- Run the migration command on this network
After the depolyment finished, a new file is generated at the root directory of the app called /delpyed-contracts.json. We will need this in the next step.
6. Add to .env File
Modify the following environment variables to your .env file with the generated contracts.json file