Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Account

Hierarchy

  • Account

Index

Constructors

  • new Account(connection: Connection, accountId: string): Account
  • Parameters

    • connection: Connection
    • accountId: string

    Returns Account

Properties

accountId: string
connection: Connection
functionCallV1: any
functionCallV2: any
signAndSendTransactionV1: any
signAndSendTransactionV2: any

Methods

  • addKey(publicKey: string | PublicKey, contractId?: string, methodNames?: string | string[], amount?: any): Promise<FinalExecutionOutcome>
  • see

    https://docs.near.org/docs/concepts/account#access-keys

    todo

    expand this API to support more options.

    Parameters

    • publicKey: string | PublicKey

      A public key to be associated with the contract

    • Optional contractId: string

      NEAR account where the contract is deployed

    • Optional methodNames: string | string[]

      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.

    • Optional amount: any

      Payment in yoctoⓃ that is sent to the contract during this function call

    Returns Promise<FinalExecutionOutcome>

  • createAccount(newAccountId: string, publicKey: string | PublicKey, amount: BN): Promise<FinalExecutionOutcome>
  • Parameters

    • newAccountId: string

      NEAR account name to be created

    • publicKey: string | PublicKey

      A public key created from the masterAccount

    • amount: BN

    Returns Promise<FinalExecutionOutcome>

  • createAndDeployContract(contractId: string, publicKey: string | PublicKey, data: Uint8Array, amount: BN): Promise<Account>
  • Create a new account and deploy a contract to it

    Parameters

    • contractId: string

      NEAR account where the contract is deployed

    • publicKey: string | PublicKey

      The public key to add to the created contract account

    • data: Uint8Array

      The compiled contract code

    • amount: BN

      of NEAR to transfer to the created contract account. Transfer enough to pay for storage https://docs.near.org/docs/concepts/storage-staking

    Returns Promise<Account>

  • Parameters

    • beneficiaryId: string

      The NEAR account that will receive the remaining Ⓝ balance from the account being deleted

    Returns Promise<FinalExecutionOutcome>

  • Parameters

    • publicKey: string | PublicKey

      The public key to be deleted

    Returns Promise<FinalExecutionOutcome>

  • Parameters

    • data: Uint8Array

      The compiled contract code

    Returns Promise<FinalExecutionOutcome>

  • fetchState(): Promise<void>
  • Returns Promise<void>

  • findAccessKey(receiverId: string, actions: Action[]): Promise<{ accessKey: AccessKeyView; publicKey: PublicKey }>
  • Finds the {@link AccessKeyView} associated with the accounts {@link PublicKey} stored in the {@link KeyStore}.

    todo

    Find matching access key based on transaction (i.e. receiverId and actions)

    Parameters

    • receiverId: string

      currently unused (see todo)

    • actions: Action[]

      currently unused (see todo)

    Returns Promise<{ accessKey: AccessKeyView; publicKey: PublicKey }>

    { publicKey PublicKey; accessKey: AccessKeyView }

  • deprecated

    Parameters

    • props: FunctionCallOptions

    Returns Promise<FinalExecutionOutcome>

  • deprecated

    Parameters

    • contractId: string

      NEAR account where the contract is deployed

    • methodName: string

      The method name on the contract as it is written in the contract code

    • args: any

      arguments to pass to method. Can be either plain JS object which gets serialized as JSON automatically or Uint8Array instance which represents bytes passed as is.

    • Optional gas: any

      max amount of gas that method call can use

    • Optional amount: any

      amount of NEAR (in yoctoNEAR) to send together with the call

    Returns Promise<FinalExecutionOutcome>

  • getAccessKeys(): Promise<AccessKeyInfoView[]>
  • Returns calculated account balance

    Returns Promise<AccountBalance>

  • getAccountDetails(): Promise<{ authorizedApps: AccountAuthorizedApp[] }>
  • Returns a list of authorized apps

    todo

    update the response value to return all the different keys, not just app keys.

    Returns Promise<{ authorizedApps: AccountAuthorizedApp[] }>

  • Parameters

    • receiverId: string

      NEAR account receiving Ⓝ

    • amount: BN

      Amount to send in yoctoⓃ

    Returns Promise<FinalExecutionOutcome>

  • Sign a transaction to preform a list of actions and broadcast it using the RPC API.

    see

    {@link JsonRpcProvider.sendTransaction}

    Parameters

    • __namedParameters: SignAndSendTransactionOptions

    Returns Promise<FinalExecutionOutcome>

  • deprecated

    Sign a transaction to preform a list of actions and broadcast it using the RPC API.

    see

    {@link JsonRpcProvider.sendTransaction}

    Parameters

    • receiverId: string

      NEAR account receiving the transaction

    • actions: Action[]

      list of actions to perform as part of the transaction

    Returns Promise<FinalExecutionOutcome>

  • Create a signed transaction which can be broadcast to the network

    see

    {@link JsonRpcProvider.sendTransaction}

    Parameters

    • receiverId: string

      NEAR account receiving the transaction

    • actions: Action[]

      list of actions to perform as part of the transaction

    Returns Promise<[Uint8Array, SignedTransaction]>

  • state(): Promise<AccountView>
  • viewFunction(contractId: string, methodName: string, args?: any, __namedParameters?: { parse?: ((response: Uint8Array) => any); stringify?: ((input: any) => Buffer) }): Promise<any>
  • Invoke a contract view function using the RPC API.

    see

    https://docs.near.org/docs/develop/front-end/rpc#call-a-contract-function

    Parameters

    • contractId: string

      NEAR account where the contract is deployed

    • methodName: string

      The view-only method (no state mutations) name on the contract as it is written in the contract code

    • Optional args: any

      Any arguments to the view contract method, wrapped in JSON

    • Optional __namedParameters: { parse?: ((response: Uint8Array) => any); stringify?: ((input: any) => Buffer) }
      • Optional parse?: ((response: Uint8Array) => any)
          • (response: Uint8Array): any
          • Parameters

            • response: Uint8Array

            Returns any

      • Optional stringify?: ((input: any) => Buffer)
          • (input: any): Buffer
          • Parameters

            • input: any

            Returns Buffer

    Returns Promise<any>

  • viewState(prefix: string | Uint8Array, blockQuery?: { blockId: BlockId } | { finality: Finality }): Promise<{ key: Buffer; value: Buffer }[]>
  • Returns the state (key value pairs) of this account's contract based on the key prefix. Pass an empty string for prefix if you would like to return the entire state.

    see

    https://docs.near.org/docs/develop/front-end/rpc#view-contract-state

    Parameters

    • prefix: string | Uint8Array

      allows to filter which keys should be returned. Empty prefix means all keys. String prefix is utf-8 encoded.

    • Optional blockQuery: { blockId: BlockId } | { finality: Finality }

      specifies which block to query state at. By default returns last "optimistic" block (i.e. not necessarily finalized).

    Returns Promise<{ key: Buffer; value: Buffer }[]>

Generated using TypeDoc