I have the following smartPy code deployed to a contract:
@sp.entry_point
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.
console.log(storageMap)
?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?catch
block. I supposed it came from the smart contract entry point itself? I don't havedata_raw
anywhere else in my JS code.new MichelsonMap()
and let me know how it goes?