【问题标题】:ReactJS not call method from Smart Contract (NEAR) on product (testnet does not exist while viewing)ReactJS 不从产品上的智能合约(NEAR)调用方法(查看时测试网不存在)
【发布时间】:2021-12-25 09:12:35
【问题描述】:

我成功部署了我的第一个应用程序(AssemblyScript + Reactjs),但是当我在 github-pages 上测试时,我得到了这个错误。

errors.js:18 Uncaught (in promise) Error: [-32000] Server error: account xxx.testnet does not exist while viewing
at json-rpc-provider.js:322
at async Object.e [as default] (exponential-backoff.js:7)
at async y.sendJsonRpc (json-rpc-provider.js:297)
at async y.query (json-rpc-provider.js:109)
at async _.viewFunction (account.js:366)

我用 near-cli 测试方法合同,没关系,所以我不明白为什么 web 不起作用。谢谢大家。

testnet does not exist while viewing

【问题讨论】:

    标签: reactjs smartcontracts nearprotocol assemblyscript near


    【解决方案1】:

    如果你将合约部署到测试网服务器(accountId 类似于 xxx.testnet),你应该删除process.env.NODE_ENVsrc/utils.js

    const nearConfig = getConfig("development");

    因为当你运行npm start 时,process.env.NODE_ENV 总是等于'development',当你运行npm test 时它总是等于'test',而当你运行npm run build 来制作一个生产包时,它总是等于“生产”。因此,如果nearConfig 是生产配置,则所有 url 都是主网服务器,而不是您部署合约的测试网服务器!

    【讨论】:

      猜你喜欢
      • 2021-06-04
      • 2020-01-16
      • 2022-06-23
      • 2020-10-02
      • 2021-05-28
      • 1970-01-01
      • 2021-03-31
      • 2019-09-09
      • 2021-12-30
      相关资源
      最近更新 更多