This repo provides a starting point for building a dapp on the renec
blockchain.
programs
: This folder contains the logic code for the program. It usesanchor
framework to build the program.app
: This folder contains FE code for the dapp. It usesnext-js
andtypescript
to build the FE.dev-scripts
: This folder contains scripts to build and deploy the program, and to setup the FE usingbash-scripts
. Support running onUnix
environemnt.tests
: This folder contains tests for theprogram
- For Linux user:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev
sudo apt install libssl-dev
- For Mac user:
brew install openssl
- For Windows user: must install make
- Install Chocolatey from here https://chocolatey.org/install
- Then run
choco install make
from a fresh terminal.
- To setup program dependencies, run:
make install-deps
This will install the anchor
and solana
cli if needed. Default solana 1.14.6
, anchor 0.25.0
To use different version compatible with renec cluster
, set the CLUSTER
and ANCHOR_VERSION
environment variables and run the command
For example:
CLUSTER=mainnet ANCHOR_VERSION=0.20.1 make install-deps
CLUSTER
can either be mainnet
, testnet
or localnet
. By setting the cluster correctly, the installer will set the corresponding cli
for program's interaction.
- To run a
localnet
that has the same version asrenec-mainnet
, run;
make localnet
- To gen a new wallet, run:
make gen-wallet name="<wallet-name>"
The wallets' screte keys will be stored in ./wallets
folder.
- To import an existing wallet, run:
make import-wallet name="<wallet-name>"
- To request faucet token in
testnet
orlocalnet
, run:
make faucet amount=1 name="<wallet-name>"
- Some free RPC providers:
- Build program:
make build
Notes:
-
This command will generate the
program keypair
if needed, and replace it insideprograms/dapp-starter/src/lib.rs
file. Then it will build the program and generateprogram so
file. -
For FE interaction, this script copies the
dapp_starter.json
,dapp_starter.ts
and replaceprogram_id
into theconfig.json
file inapp/src/artifacts
folder. -
Deploy program:
CLUSTER=mainnet make deploy name="<wallet-name>"
Notes:
This command deploy the program, under .wallets/<wallet-name>.json
authority. The program will be deploy to CLUSTER
env, which could either be localnet
, mainnet
or testnet
-
The frontend is built with
next-js
andtypescript
. It uses@project-serum/anchor
to interact with the program. -
The FE uses daemon-wallet to connect with
renec-blockchain
. -
The provided program and the FE provide a simple
counter
program, which allows users toinitialize a counter
, andincrement
the count in thatcounter
.
- Node.js 16.8.0 or newer
build and deploy
the program to therenec testnet
. Make sure that you've runmake build
andCLUSTER=testnet make deploy
before running the frontend.
cd app
yarn && yarn dev
To reduce the time to convert and rebuild programs from solana. We have supported scripts to quickly re-deploy programs to renc from previously built programs.
Bash script params annotation:
- program_file_path
: Path to the program file used to deploy on Solana
- keypair_path
: Path to the keypair used to deploy on Solana
- program_id_keypair
: Path to the program id keypair used to deploy on Solana
Deploy on Renec-Testnet
CLUSTER=testnet make port-dapp program_file_path=path/to/program_file.so keypair_path=path/to/wallet.json program_id_keypair=path/tp/program-id/keypair.json
Deploy on Renec-Mainnet
CLUSTER=mainnet make port-dapp program_file_path=path/to/program_file.so keypair_path=path/to/wallet.json progran_id_keypair=path/tp/program-id/keypair.json