简体   繁体   English

近协议 | RPC 合约部署 | 反序列化错误

[英]Near Protocol | RPC Contract deployment | Deserialization error

I am developing smart contracts in AssemblyScript, deploying contracts via RPC (Remote Procedural Calls), that is dynamically, while coding as and when required.我正在使用 AssemblyScript 开发智能合约,通过 RPC(远程过程调用)动态部署合约,同时根据需要进行编码。 Below is the code that carries out this task.下面是执行此任务的代码。

log(): void {
logging.log(this.owner);

const access_key = base58.decode(Context.senderPublicKey);
logging.log(access_key);

const CODE = base58.decode("build/release/nft.wasm");

ContractPromiseBatch
  .create("d4." + this.owner)
  .create_account()
  .transfer(ONE_NEAR)
  .add_full_access_key(access_key)
  .deploy_contract(CODE);
}

After the code the new account has been created and the contract code deployed, I get a deserialization error even while carrying out the init calls for initialising the contract.在创建新帐户的代码并部署合约代码之后,即使在执行初始化合约的 init 调用时,我也会收到反序列化错误。

The error log is:错误日志是:

Failure:
{
  "ActionError": {
    "index": 0,
    "kind": {
      "FunctionCallError": {
        "CompilationError": {
          "PrepareError": "Deserialization"
        }
      }
    }
  }
}

The link to the transaction: https://explorer.tes.net.near.org/transactions/2HjNsq6ytnN3hT9odoijaYxBsByhQQcwSUTZNwGgzuyg交易链接: https://explorer.tes.net.near.org/transactions/2HjNsq6ytnN3hT9odoijaYxBsByhQQcwSUTZNwGgzuyg

Heres the init method of the contract I am trying to initialize这是我要初始化的合约的 init 方法

在此处输入图像描述

It appears the correct way to include your wasm code while deploying the contract is在部署合同时包含您的 wasm 代码的正确方法似乎是

const CODE = includeBytes("../../../build/release/nft.wasm");

and while deploying, parse CODE into base58 array并在部署时将 CODE 解析为 base58 数组

let promise = ContractPromiseBatch
  .create("kust" + "." + this.owner)
  .create_account()
  .transfer(ONE_NEAR)
  .add_full_access_key(access_key)
  .deploy_contract(Uint8Array.wrap(changetype<ArrayBuffer>(CODE)));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM