Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eigo-mt-fuji/nextjs-neardev-rust-template
my dApp template of NEAR Blockchain smart contract in Rust and frontend in Next.js(Typescript)
https://github.com/eigo-mt-fuji/nextjs-neardev-rust-template
nearprotocol nextjs rust serverless-framework smartcontract-dapp terraform typescript
Last synced: about 1 month ago
JSON representation
my dApp template of NEAR Blockchain smart contract in Rust and frontend in Next.js(Typescript)
- Host: GitHub
- URL: https://github.com/eigo-mt-fuji/nextjs-neardev-rust-template
- Owner: Eigo-Mt-Fuji
- Created: 2022-08-17T06:58:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-28T13:05:11.000Z (over 2 years ago)
- Last Synced: 2024-04-24T10:28:06.430Z (8 months ago)
- Topics: nearprotocol, nextjs, rust, serverless-framework, smartcontract-dapp, terraform, typescript
- Language: Rust
- Homepage:
- Size: 322 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# README
## About
- My dApp template of NEAR Blockchain smart contract in Rust and frontend in Next.js(Typescript)
## Background
- [note - Rust/DApp実習 - はじめました](https://note.com/efujikawa/n/n67d8c5d5b868?magazine_key=m2b7793629425)
- [note - イーサリアム学ぶ夏休みのまとめ](https://note.com/efujikawa/n/n2f4f03ef03fd)
- [note - Rust学習まとめ 学習のふりかえり](https://note.com/efujikawa/n/n0d2aa27b6bc7)
- [note - ブロックチェーン自由研究 - NEARについて理解する](https://note.com/efujikawa/n/n1a6fbbb5d981?magazine_key=m970875a701ac)## Environments
| Name | Version |
|:----:|:----:|
| `OS` | macOS 10.15.5(Intel) |
| NodeJs | 16.16.0 |
| Rust | 1.62.1 |
| Terraform | 1.2.7 |
| Serverless Framework | 2.72.* |
| AWS-cli | 2.5.3 |
| NextJs | 12.* |
| React | 18.* |
| Emotion/react | 11.* |## Architecture Overview
[![img](./architecture.png)](architecture.drawio.svg)
## How to use
### Smart contract build and deploy
- Build
```
npm run build:contract
```- Deploy SmartContract to testnet
```
npm run dev:deploy:contract
```### Prepare Frontend(next.js) .env.local
- Open contracts/neardev/dev-account.env and check contract name
```
$ cat contracts/neardev/dev-account.env
CONTRACT_NAME=dev-1660474152460-14596747053304
```- Put .env.local file for next.js
```
touch .env.local
cat < [email protected] deploy:serverless:test
> cp serverless.test.yml serverless.yml && components-v1 && rm -rf serverless.ymlawesomeRustDapp:
appUrl: https://awesome-rust-dapp.efgriver.com
bucketName: v2j8wjn-k5ncpd8
distributionId: E1WHCQULHESL5I287s › awesomeRustDapp › done
```### Unit test(rust)
```
npm run test:unit
```### Integration test(next.js / cypress)
- start dev server
```
npm run dev
```- open another terminal
- start integration test
- after cypress launched successfully, choose E2E and run each test spec manually.```
npm run test:integration:ts
```### Deploy frontend app AWS(test)
```
NEXT_PUBLIC_CONTRACT_NAME=dev-1660474152460-14596747053304
SERVERLESS_ACCESS_KEY=my secret key
SLS_STAGE=test
```- try deploy serverless deploy
```
export SERVERLESS_ACCESS_KEY=my secret key
source frontend/.env.local
npm run deploy:serverless
```## Note: Directory Tree
- Main component in japanese
- `dAppフロントエンドソースコード置き場(Next.js)`
- `サーバレスインフラコード(Serverless Framework)`
- `dAppバックエンドソースコード置き場(NEAR Smart Contract)`
- `スマートコントラクト結合テストコード`
- `E2Eテストコード(Cypress)`
- `IaCコード(Terraform)`
- `CI/CD設定(Github Actions Workflow)`
- `サーバレスインフラコード(Serverless Framework)````
nextjs-neardev-rust-template├── README.md
├── next-env.d.ts
├── next.config.js
├── package.json # ビルド・デプロイスクリプト(NPM script)
├── package-lock.json
├── tsconfig.json
├── src # dAppフロントエンドソースコード置き場(Next.js)
│ ├── components
│ │ └── Form.tsx
│ ├── near-env-config.ts
│ ├── near-init-contract.ts
│ ├── pages
│ │ ├── _app.tsx
│ │ ├── api
│ │ └── index.tsx
│ ├── public
│ │ ├── favicon.ico
│ │ └── vercel.svg
│ ├── styles
│ │ ├── Home.module.css
│ │ └── globals.css
│ └── types.ts
├── contracts # dAppバックエンドソースコード置き場(NEAR Smart Contract)
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── integration-tests # スマートコントラクト結合テストコード
│ │ └── rs
│ │ ├── Cargo.toml
│ │ └── src
│ │ └── tests.rs
│ ├── neardev
│ │ ├── dev-account
│ │ └── dev-account.env
│ ├── src
│ │ └── lib.rs
│ └── target
│ └── wasm32-unknown-unknown
├── cypress # E2Eテストコード(Cypress)
│ ├── downloads
│ ├── e2e
│ │ ├── index.d.ts
│ │ └── spec.cy.ts
│ ├── fixtures
│ │ └── example.json
│ └── support
│ ├── commands.ts
│ └── e2e.ts
├── cypress.config.js
├── terraform # IaCコード(Terraform)
│ └── components
│ └── backend
│ ├── README.md
│ ├── apply.sh
│ ├── iam.tf
│ ├── main.tf
│ ├── output.tf
│ ├── providers.tf
│ ├── templates
│ │ ├── github-workflow-assume-role-policy.json
│ │ └── github-workflow-iam-policy.json
│ ├── terraform.plan
│ └── variables.tf
├── .github
│ └── workflows # CI/CD設定(Github Actions Workflow)
│ ├── deploy-aws-serverless.yml
│ └── tests.yml
└── serverless.test.yml # サーバレスインフラ設定(Serverless Framework)
```