near-api-js - v7.0.4
    Preparing search index...

    This class allows to access common account information. If a Signer is provider, then the account can be used to perform all common actions such as transferring tokens and calling functions

    Index

    Constructors

    Properties

    accountId: string
    provider: Provider

    Methods

    • Creates a new NEAR account with a given ID and public key.

      This method can create two types of accounts:

      1. Top-level accounts of the form name.tla (e.g., bob.near):

      2. Sub-accounts of the current account (e.g., sub.ana.near):

        • The new account ID must end with the current account ID
        • Example: If your account is ana.near, you can create sub.ana.near

      Parameters

      • options: CreateAccountArgs

        Account creation options

        • OptionalnearToTransfer?: string | number | bigint
        • newAccountId: string
        • publicKey: string | PublicKey

      Returns Promise<RpcTransactionResponse>

    • Deletes the account, transferring all remaining NEAR to a beneficiary account

      Important: Deleting an account does not transfer FTs or NFTs

      Parameters

      • beneficiaryId: string

        Will receive the account's remaining balance

      Returns Promise<RpcTransactionResponse>

    • Deploy a global contract that can be reused by multiple accounts

      Parameters

      • code: Uint8Array

        The compiled contract code bytes

      • deployMode: "accountId" | "codeHash"

        Deploy mode - "codeHash" for immutable contracts, "accountId" for updateable contracts

      Returns Promise<RpcTransactionResponse>

    • Calls Provider.viewAccessKeyList to retrieve the account's keys

      Returns Promise<AccessKeyList & { block_hash: string; block_height: number }>

    • Calls Provider.viewContractState to retrieve the keys and values stored on the account's contract

      Parameters

      • Optionalprefix: string

      Returns Promise<ViewStateResult & { block_hash: string; block_height: number }>

    • Allows to set the signer used to control the account

      Parameters

      • signer: Signer

        holds the private key and can sign Transactions

      Returns void

    • This function simply calls the signNep413Message method of the Signer

      Parameters

      • args: SignNep413MessageArgs

        Nep413 message signing arguments

        • OptionalcallbackUrl?: string
        • message: string
        • nonce: Uint8Array
        • recipient: string

      Returns Promise<SignedMessage>

      This method is deprecated and will be removed in future versions. Please use signMessage from near-api-js/nep413 to sign NEP-413 messages.

    • Use a previously deployed global contract on this account

      Parameters

      • contractIdentifier: { accountId: string } | { codeHash: string | Uint8Array<ArrayBufferLike> }

        The global contract identifier - either { accountId: string } or { codeHash: string | Uint8Array }

      Returns Promise<RpcTransactionResponse>