Near Protocol | RPC Contract deployment | Deserialization error

261 Views Asked by At

I am developing smart contracts in AssemblyScript, deploying contracts via RPC (Remote Procedural Calls), that is dynamically, while coding as and when required. 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.

The error log is :

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

The link to the transaction : https://explorer.testnet.near.org/transactions/2HjNsq6ytnN3hT9odoijaYxBsByhQQcwSUTZNwGgzuyg

Heres the init method of the contract I am trying to initialize

enter image description here

1

There are 1 best solutions below

1
On

It appears the correct way to include your wasm code while deploying the contract is

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

and while deploying, parse CODE into base58 array

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)));