Skip to content

Near

When running a DApp in the Bitget Wallet App or in the Chrome browser with the Chrome Extension installed, you can access the global object window.bitkeep.near for subsequent API calls.

js
const provider = window.bitkeep.near
const provider = window.bitkeep.near

Injected object properties and methods

  • getAccountId - () => string: Get account ID
  • getPublicKey - () => string: Get public key
  • requestSignIn - (params) => Promise: Request sign-in
  • isSignedIn - () => Boolean: Check if signed in
  • signOut - () => Promise: Sign out
  • signAndSendTransaction - (param) => Promise: Sign and send transaction
  • verifyOwner - (message, accountId) => Promise: Verify owner
  • requestSignTransactions - ({ transactions }) => Promise: Request transaction signatures

requestSignIn

Given the required view and change methods, return an access key (response may change in future versions).

js
/**
* request signin the contract, with the view and change methods provided, return the access key
* @param {*} contractId contract account id
* @param {*} methodNames the method names on the contract that should be allowed to be called. Pass null for no method names and '' or [] for any method names.
* @param {*} createNew if need create new access key, set createNew = true. Default is false
* @returns { accessKey } signed in access key
*/
provider.requestSignIn({ contractId, methodNames, createNew = false }): Promise<Result>
/**
* request signin the contract, with the view and change methods provided, return the access key
* @param {*} contractId contract account id
* @param {*} methodNames the method names on the contract that should be allowed to be called. Pass null for no method names and '' or [] for any method names.
* @param {*} createNew if need create new access key, set createNew = true. Default is false
* @returns { accessKey } signed in access key
*/
provider.requestSignIn({ contractId, methodNames, createNew = false }): Promise<Result>
js
const contractId = 'guest-book.testnet';
const methodNames = ['addMessage'];
const res = await provider.requestSignIn({ contractId, methodNames });
const contractId = 'guest-book.testnet';
const methodNames = ['addMessage'];
const res = await provider.requestSignIn({ contractId, methodNames });

Sign Out Access Key

Sign out the access key from this account and clear the signed-in access key from storage. If a DApp has multiple contractIds, the specific contractId must be passed.

js
/**
* @param {*} contractId contract account id (options)
*/
near.signOut({ contractId }): Promise<Result>;
/**
* @param {*} contractId contract account id (options)
*/
near.signOut({ contractId }): Promise<Result>;

isSignedIn

If a DApp has multiple contractIds, the specific contractId must be passed.

js
/**
* @param {*} contractId contract account id (options)
*/
near.isSignedIn({ contractId }): boolean;
/**
* @param {*} contractId contract account id (options)
*/
near.isSignedIn({ contractId }): boolean;

getPublicKey

Get public key

js
/**
* @param {*} contractId contract account id (options)
*/
await near.getPublicKey(): string;
/**
* @param {*} contractId contract account id (options)
*/
await near.getPublicKey(): string;

verifyOwner

Verify Owner

js

await near.verifyOwner(message, accountId, networdkId): boolean;

await near.verifyOwner(message, accountId, networdkId): boolean;

signAndSendTransaction

Sign and Send a Transaction

js

near.signAndSendTransaction({ receiverId: string, actions: Action}): Response;

near.signAndSendTransaction({ receiverId: string, actions: Action}): Response;

signAndSendTransactions

Sign and Send Multiple Transaction RPC Requests

js

near.signAndSendTransactions({ receiverId: string, actions: Action}): Response;

near.signAndSendTransactions({ receiverId: string, actions: Action}): Response;