Table of Contents
This project is created for easy-to-start as a React + IPFS skeleton template in the Pagoda Gallery. It was initialized with create-near-app. Clone it and start to build your own gallery project!
create-near-app, amazing-github-template
Make sure you have a current version of Node.js installed – we are targeting versions 18+
.
Read about other prerequisites in our docs.
Install all dependencies:
npm install
Install IPFS:
npm install -g ipfs
Initialize IPFS daemon:
jsipfs init
Allow our clients to talk to our jsipfs instance:
jsipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://localhost:5002", "http://localhost:3000", "https://webui.ipfs.io"]'
jsipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
Build your contract:
npm run build
Deploy your contract to TestNet with a temporary dev account:
npm run deploy
Test your contract (must use node v16):
npm test
Start your IPFS daemon:
jsipfs daemon
Run your frontend in development mode:
npm run dev
Start your frontend in production mode:
npm start
- 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. - The frontend code lives in the
/frontend
folder./frontend/pages/index.tsx
is a great place to start exploring. Note that it uses/frontend/contracts/ipfs-contract.ts
, this is your entrypoint to learn how the frontend connects to the NEAR blockchain.
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:
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
)
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
:
-
Authorize NEAR CLI, following the commands it gives you:
near login
-
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
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
Modify NEXT_PUBLIC_CONTRACT_NAME
in frontend/.env.local
that sets the account name of the contract. Set it to the account id you used above.
NEXT_PUBLIC_CONTRACT_NAME=near-blank-project.YOUR-NAME.testnet
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.
See the open issues for a list of proposed features (and known issues).
- Top Feature Requests (Add your votes using the 👍 reaction)
- Top Bugs (Add your votes using the 👍 reaction)
- Newest Bugs
Reach out to the maintainer:
If you want to say thank you or/and support active development of Boilerplate Template React:
- Add a GitHub Star to the project.
- Tweet about the Boilerplate Template React.
- Write interesting articles about the project on Dev.to, Medium or your personal blog.
Together, we can make Boilerplate Template React better!
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!
The original setup of this repository is by Jonathan Lewis.
For a full list of all authors and contributors, see the contributors page.
Boilerplate Template React follows good practices of security, but 100% security cannot be assured. Boilerplate Template React 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.