---
# System prepended metadata

title: Untitled

---


## Contents:
### Smart Contracts and Metadata
This project includes the following smart contracts and their metadata:
- [Smart Contracts](./src)
  - Redistribution
  - Staking Registry
  - Price Oracle
  - Postage Stamps
    - HitchensOrderStatisticsTreeLib
  - Test Token


- Metadata ([Testnet](./testnet_deployed.json),[Mainnet](./mainnet_deployed.json))
  - **Chain ID**: Chain ID of the blockchain.
  - **Network ID**: Network ID.
  - **ABI**: Interface to communicate with smart contracts.
  - **Bytecode**: Compiled object code that is executed during communication with smart contract.
  - **Address**: Address of the deployed contract on blockchcain.
  - **Block**: Block height in which the transaction is mined.
  - **URL**: URL for analyzing the transaction.

### [Scripts](./scripts)
- Script for deploying all and individual contracts
- Script assigning roles/permissions for smart contracts
  - Redistributor roles

## Project Setup
### Prerequisites
To set up the project, you will need `yarn` and `node`.

The project has been tested with the latest node LTS (Erbium). A `.nvmrc` file is also provided.

### Setup
To get started with this project, follow these steps:

1. Clone the repo.
2. Run `yarn install` at the root of the repo to install all dependencies.
3. Add a `.env` file in your root directory, where you'll store your sensitive information for deployment. An example file [`.env.example`](./.env.example) is provided for reference.

## Run

### [Tests](./test)
- Unit Tests
  - Run `npm run test` to run all the tests.
  - Run `npm run test:coverage` to see the coverage of smart contracts.

### Deployments

#### Remote
##### Prerequisites
Consult devops/storage-incentives team for infura token or create one from [Infura website](https://infura.io/).

##### Steps
1. Run `npm run compile` to get all the contracts compiled.
2. Run `npm run test` to run all the tests.
3. Configure `.env` file
   - Add your wallet `Mnemonic` in `.env` file.
   - Add your `Infura` token in `.env` file.
4. To deploy all contracts and set roles:
   - Mainnet: `npm run deploy:mainnet`
   - Testnet: `npm run deploy:testnet`

**Note:** After successfully deploying to mainnet or testnet the [mainnet_deployed.json](./mainnet_deployed.json) and [testnet_deployed.json](./testnet_deployed.json) will be automatically updated and those changes should be committed if intended.

#### Local
- Run `npm run deploy:hardhat` to deploy all contracts on hardhat environment(network).
- To deploy on Ganache (or other networks):
  - Add network configuration in your [hardhat.config.ts](./hardhat.config.ts).
      ```
      - ganache: {
            url: 'http://localhost:8545',
            chainId: 1337,
      },
      ```
  - To run: `npm run deploy ganache`


#### Additional commands and flags:
* Make necessary changes to [hardhat.config.ts](./hardhat.config.ts).
  * List of available configs can be found [here](https://hardhat.org/hardhat-runner/docs/config).
* Run script `npx hardhat run <script> --network <network>`
  - **Network**: Configure network name
  - **Script**: Configure script name and path
     

