I am trying to follow the near zero to hero nft example which is described with cli commands. I it working with cli commands but struggling to convert it to javascript. In particular I am trying to simply call a view script on the nft contract which has been deployed to a subaccount. So I load the account;
this.nft_contract = await this._near.near.loadContract(this.nft_contract_id, {
viewMethods: ["nft_metadata","nft_token","nft_payout","nft_is_approved","nft_tokens","nft_supply_for_owner","nft_tokens_for_owner"],
// Change (“call”) methods can modify the state. But you don't receive the returned value when called.
changeMethods: ["new_default_meta","new","nft_mint","nft_transfer","nft_transfer_call","nft_transfer_payout","nft_approve","nft_revoke","nft_revoke_all"],
sender: window.walletConnection.getAccountId()
});
and then call the view function nft_metadata as shown the the zero to hero example, but with js as follows;
await this.nft_contract.nft_metadata()
I get the error missing field account_id
, which I can only assume relates to the backend rpc call. The cli example explicitly states the account_id argument, but any examples ive seen to call a contract argument dont give that option. Is is something to do with how my code logs in?
This project should answer most questions about calling your contract from the frontend