Integrating Contracts
To integrate NEAR to your frontend, you will leverage two tools:
Wallet Selector
: Enables the user to select their preferred NEAR wallet in your dApp.NEAR API JS
: NEAR RPC와 상호 작용하는 도구 세트입니다.
이러한 도구를 사용하여 다음 흐름을 구현합니다.
- wallet selector를 설정합니다.
- 시작할 때 wallet selector를 로드합니다.
- 사용자에게 NEAR 지갑을 사용하여 로그인하도록 요청합니다.
- Call methods in the contract.
NEAR API JS 및 Wallet Selector 추가
near-api-js
및 wallet-selector
를 사용하려면, 먼저 프로젝트에 이를 추가해야 합니다.
해당 웹사이트를 확인해 보세요.
npm install \
near-api-js \
@near-wallet-selector/core \
@near-wallet-selector/my-near-wallet \
@near-wallet-selector/ledger \
@near-wallet-selector/modal-ui
Create a Wallet Object
In our examples we implement a ./wallets/near.js
module, where we abstracted the wallet selector
into a Wallet
object to simplify using it.
To create a wallet, simply import the Wallet
object from the module and initialize it. This wallet
will later allows the user to call any contract in NEAR.
- 🌐 Javascript
- _app.js
- 1
Loading...
<Github fname="near.js"
url="https://github.com/near-examples/hello-near-examples/blob/main/frontend/src/wallets/near.js"
start="15" end="142" />