Skip to content

near/boilerplate-template-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rust Boilerplate Template

Report a Bug Β· Request a Feature . Ask a Question

Pull Requests welcome code with love by near

Table of Contents

About

This is a Next.js project bootstrapped with create-next-app and tailwindcss created for easy-to-start as a React + Rust skeleton template in the Pagoda Gallery. Smart-contract was initialized with create-near-app. Use this template and start to build your own gallery project!

Built With

create-next-app, tailwindcss, tailwindui, @headlessui/react, @heroicons/react, create-near-app, amazing-github-template

Getting Started

Prerequisites

Make sure you have a current version of Node.js installed – we are targeting versions 18>.

Read about other prerequisites in our docs.

Installation

Install all dependencies:

npm install

Build your contract:

npm run build

Deploy your contract to TestNet with a temporary dev account:

npm run deploy

Usage

Start your frontend:

npm run start

Open http://localhost:3000 with your browser to see the result.

Test your contract:

npm run test

Exploring The Code

  1. The smart-contract code lives in the /contract folder. See the README there for more info. In blockchain apps the smart contract is the "backend" of your app.
  2. The frontend code lives in the /frontend folder. You can start editing the page by modifying frontend/pages/index.tsx. The page auto-updates as you edit the file. This is your entrypoint to learn how the frontend connects to the NEAR blockchain.
  3. Test your contract: npm test, this will run the tests in integration-tests directory.
  4. API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in frontend/pages/api/hello.ts.
  5. The frontend/pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.
  6. This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Deploy

Every smart contract in NEAR has its own associated account. When you run npm run deploy, your smart contract gets deployed to the live NEAR TestNet with a temporary dev account. When you're ready to make it permanent, here's how:

Step 0: Install near-cli (optional)

near-cli is a command line interface (CLI) for interacting with the NEAR blockchain. It was installed to the local node_modules folder when you ran npm install, but for best ergonomics you may want to install it globally:

npm install --global near-cli

Or, if you'd rather use the locally-installed version, you can prefix all near commands with npx

Ensure that it's installed with near --version (or npx near --version)

Step 1: Create an account for the contract

Each account on NEAR can have at most one contract deployed to it. If you've already created an account such as your-name.testnet, you can deploy your contract to near-blank-project.your-name.testnet. Assuming you've already created an account on NEAR Wallet, here's how to create near-blank-project.your-name.testnet:

  1. Authorize NEAR CLI, following the commands it gives you:

    near login

  2. Create a subaccount (replace YOUR-NAME below with your actual account name):

    near create-account near-blank-project.YOUR-NAME.testnet --masterAccount YOUR-NAME.testnet

Step 2: deploy the contract

Use the CLI to deploy the contract to TestNet with your account ID. Replace PATH_TO_WASM_FILE with the wasm that was generated in contract build directory.

near deploy --accountId near-blank-project.YOUR-NAME.testnet --wasmFile PATH_TO_WASM_FILE

Step 3: set contract name in your frontend code

Modify the line in contract/neardev/dev-account.env that sets the account name of the contract. Set it to the account id you used above.

CONTRACT_NAME=near-blank-project.YOUR-NAME.testnet

Troubleshooting

On Windows, if you're seeing an error containing EPERM it may be related to spaces in your path. Please see this issue for more details.

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

Roadmap

See the open issues for a list of proposed features (and known issues).

Support

Reach out to the maintainer:

Project assistance

If you want to say thank you or/and support active development of Rust Boilerplate Template:

  • Add a GitHub Star to the project.
  • Tweet about the Rust Boilerplate Template.
  • Write interesting articles about the project on Dev.to, Medium or your personal blog.

Together, we can make Rust Boilerplate Template better!

Contributing

First off, thanks for taking the time to contribute! Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.

Please read our contribution guidelines, and thank you for being involved!

Authors & contributors

The original setup of this repository is by Dmitriy Sheleg.

For a full list of all authors and contributors, see the contributors page.

Security

Rust Boilerplate Template follows good practices of security, but 100% security cannot be assured. Rust Boilerplate Template is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published