Spun off from https://github.com/cemfahli/near-counter-dapp
The contract must be built and deployed separately from the front-end of the dapp. The near-sdk is used to build the smart contract, while the NEAR CLI is used to deploy it onto the chain. You must create an account first
From the near-counter directory, build by running:
env RUSTFLAGS='-C link-arg=-s' cargo build --target wasm32-unknown-unknown --release
Login with the account you wish to deploy to:
near login
From the near-counter directory, deploy by running:
near deploy --wasmFile target/wasm32-unknown-unknown/release/rust_counter_tutorial.wasm --accountId YOUR_ACCOUNT_HERE
where YOUR_ACCOUNT_HERE is the account you previously logged into
There are several environmental variables used while building the front-end. The defaults can be seen in the .env
file and can be overwritten.
The descriptions of the variables are:
CONTRACT_ACCOUNT
: The account id you will be deploying the contract toAPP_NAME
: The name of your applicationVIEW_METHODS
: Space delimited string of your contract's view methods (methods that don't change state/require gas)CHANGE_METHODS
: Space delimited string of your contract's call methods (methods that change state/require gas)NETWORK_ID
, NODE_URL
, WALLET_URL
, HELPER_URL
, EXPLORER_URL
: Network specific configuration set according to https://docs.near.org/docs/api/naj-quick-reference#connectOnce the environmental variables are set (or the defaults are used), the front-end can be built:
npm i
npm run build
you can also serve a development environment with live reloading using:npm run dev
or serve a build with:npm run start