# Environment Set Up

## [sCrypt](https://scrypt.io/)

MVC smart contract development uses the sCrypt development suite. The sCrypt language is divided into two major versions.

### [scrypt classic](https://scrypt-ide.readthedocs.io/en/latest/getting_started.html)

Smart contracts are written in scrypt classic with contract source files ending in .scrypt. They are compiled to [bvm bytecode](https://en.bitcoin.it/wiki/Script#Constants) using scryptc, and instantiated, tested, and deployed on-chain using scryptlib. The official recommendation is to not use it anymore.&#x20;

<figure><img src="https://3872324389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy4gNPZSNO766WE54DILO%2Fuploads%2FKjgi7eqBxsWlMaKq8bbn%2Fimage.png?alt=media&#x26;token=11dacfd1-f4a3-4b11-befc-bd462e4c2f37" alt=""><figcaption></figcaption></figure>

### [scrypt](https://docs.scrypt.io/)

Smart contracts are written in TypeScript with contract source files ending in .ts. The process involves scrypt-ts-transpiler transpiling .ts to .scrypt, scryptc compiling to bvm bytecode, and scrypt-ts instantiating, constructing transactions, testing contracts, and deploying them on-chain.

* Log bvm runtime variables
* Write only in TypeScript, facilitating front-end and back-end integration
* Package as npm packages, facilitating contract reuse and distribution

<figure><img src="https://3872324389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy4gNPZSNO766WE54DILO%2Fuploads%2FbuEJIu2YlWt8SVi4rVVv%2Fimage.png?alt=media&#x26;token=e19bf65a-5719-488a-8b69-e3f97b514a7b" alt=""><figcaption></figcaption></figure>

### mvc contracts

The mvc contracts were developed using scrypt classic as scrypt was not yet fully developed. Below are the development types and project addresses for several contracts.

| Contract                                                     | Development Type        |
| ------------------------------------------------------------ | ----------------------- |
| [token-core](https://github.com/mvc-labs/token-core)         | scrypt classic          |
| [nft-core](https://github.com/mvc-labs/nft-core)             | scrypt classic          |
| [mvcdao-core](https://github.com/mvc-labs/mvcdao-core)       | scrypt classic          |
| [token-core-ts](https://github.com/xiangpengm/token-core-ts) | scrypt classic + scrypt |

The token-core-ts project translates MVC's original token and NFT contracts into scrypt, but the test cases still use scrypt classic, so the development type is a mix of both. Since the scrypt-ts library is primarily for BSV and cannot be directly used on the MVC chain, it is adapted for MVC using [patch-package](https://github.com/ds300/patch-package), as detailed below.

## The First MVC sCrypt Contract Project

### [Create a Project Using scrypt-cli](https://docs.scrypt.io/installation)

```bash
npx scrypt-cli project demo
cd demo && npm i
```

<figure><img src="https://3872324389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy4gNPZSNO766WE54DILO%2Fuploads%2FXKFl84I5sO5Oe3crTsPf%2Fimage.png?alt=media&#x26;token=5a97e849-60af-4a05-98b9-7c30e32b15ba" alt=""><figcaption></figcaption></figure>

### Add Patch Command

Add the patch command to package.json

<figure><img src="https://3872324389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy4gNPZSNO766WE54DILO%2Fuploads%2F4rIEr5fSi0ToQPKmEhbq%2Fimage.png?alt=media&#x26;token=21c2d889-dc2d-421c-abc1-1e2c7742e32a" alt=""><figcaption></figcaption></figure>

```
"patch": "sh -c \"$(curl -fsSL https://raw.githubusercontent.com/xiangpengm/token-core-ts/main/patches/patch_1.3.31.sh)\""
```

### Apply Patch

```bash
npm run patch
```

<figure><img src="https://3872324389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy4gNPZSNO766WE54DILO%2Fuploads%2Fh2Eb4Ei7mvwlumbTfXPi%2Fimage.png?alt=media&#x26;token=dfc963e8-3e32-4ea0-8560-9040b030cb47" alt=""><figcaption></figcaption></figure>

### Run scrypt-ts Local Tests

```bash
npm run test
```
