I have the following smartPy code deployed to a contract:

def add(self, id, data_raw):
    sp.set_type(id, sp.TString)
    sp.set_type(data_raw, sp.TMap(sp.TString, sp.TString))
    self.data.mapping[id] = sp.record(
        data = data_raw,

Now I want to call this contract with Taquito like this:

const id = "test_id"
const storageMap = MichelsonMap.fromLiteral({
    "1": "Test",
    "2": "Test2"

return tezos.wallet.at(accountSettings.contractAddress)
    .then((contract) => {
        reportResult("Sending...", "info", "#result-bar");
        return contract.methods.add(id, storageMap).send();
    .then((op) => {
        reportResult("Waiting for confirmation...", "info", "#result-bar");
        return op.confirmation(1).then(() => op.hash);
    .catch((error) => {
        reportResult(error.message, "error", "#result-bar");

But I get the error [data_raw] Value must be a MichelsonMap. Is there an issue with me passing the MichelsonMap to a contract entry point? I see this is viable here, but I cannot see the contract example.

Edit 1: This is what I get when console.log(storageMap) enter image description here

  • What do you get when you console.log(storageMap)? Mar 16, 2022 at 16:48
  • @ClaudeBarde Added a picture of the console,log return.
    – user8188
    Mar 16, 2022 at 18:50
  • I don't understand why you would have an error in Taquito about data_raw when that variable doesn't appear in your JavaScript code, but only in your SmartPy code. Did you leave other parts of your JS code out? Mar 16, 2022 at 18:57
  • @ClaudeBarde I left out the dependencies and connection to wallet. It's mostly the sample code from beacon. The error I get is from the catch block. I supposed it came from the smart contract entry point itself? I don't have data_raw anywhere else in my JS code.
    – user8188
    Mar 16, 2022 at 19:08
  • Can you try to pass an empty map with new MichelsonMap() and let me know how it goes? Mar 16, 2022 at 19:13

2 Answers 2


You can use michelson-sdk (Taquito example) to generate the Michelson values (Micheline or Michelson JSON).

You want something like this:

import { Record, String, Map } from "@tezwell/michelson-sdk/literal";

const storage = Record({
  id: String("test_id"),
  data_raw: Map([
    [String("1"), String("Test")],
    [String("2"), String("Test2")]

console.log("Michelson JSON: ", storage.toJSON());
  • After trying for hours to run this package with parceljs, it actually doesn't work, and gives me the same error
    – user8188
    Mar 16, 2022 at 15:10
  • What error are you getting? Mar 16, 2022 at 21:21

In my case, the main problem was in SmartPy inverting the parameters of my generated method. So while I defined the following method:

add(id, storageMap)

On chain it was generated as

add(storageMap, id)

I'm not sure if that's a SmartPy bug or is by design, but what I called in Taquito and worked is this:

return contract.methods.add(storageMap, id).send();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.