Near Protocol: Error during Context.predecessor in view

Viewed 173

I'm trying to get sender accountId in contract and getting error.

My contract:

@nearBindgen
export class Contract {
  private message: string = 'Hello '

  helloWorld(): string {
    const predecessor = Context.predecessor
    return this.message + predecessor
  }
}

I'm trying to access contract from CLI with following command(with my account id):

near view $CONTRACT helloWorld --accountId <id>.testnet

Error:

Error: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(ProhibitedInView { method_name: "predecessor_account_id" })).
1 Answers

Oops. I should use

near call

instead of

near view
Related