This example demonstrates how to integrate your application with NEAR Wallet. The contract is quite simple. It can store the account_id of last sender and return it. It also shows how you can debug contracts using logs.
There are two ways to run this project. The first is the quick and a good way to instantly become familiar with this example. Once familiar, the next step is for a developer to create their own NEAR account and deploy the contract to testnet. This is covered in the following section.
There's a button at the top of this file that says "Open in Gitpod." This will open the project in a new tab with an integrated development environment. The other option is to clone this repository and follow the same instructions.
- Install dependencies:
yarn
- Build and deploy this smart contract to a development account. This development account will be created automatically and is not intended for reuse:
yarn dev
Your command line which will display a link to localhost similar to:
Server running at http://localhost:1234
Please open that link your browser to continue and see how to log in with NEAR Wallet in a simple webapp.
In this second option, the smart contract will get deployed to a specific account created with the NEAR Wallet.
- Ensure
near-shell
is installed by running:
near --version
If needed, install near-shell
:
npm install near-shell -g
- If you do not have a NEAR account, please create one with NEAR Wallet.
In the project root, login with near-shell
by following the instructions after this command:
near login
- Modify the top of
src/config.js
, changing theCONTRACT_NAME
to be the NEAR account that was just used to log in.
…
const CONTRACT_NAME = process.env.CONTRACT_NAME || 'YOUR_ACCOUNT_NAME_HERE'; /* TODO: fill this in! */
…
- Start the example!
yarn start
yarn asp // as-pect tests
yarn jest // integration tests
yarn test // both
assembly/main.ts
for the contract codesrc/index.html
for the front-end HTMLsrc/main.js
for the JavaScript front-end code and how to integrate contractssrc/test.js
for the JS tests for the contract