Can we do something similar to myMap.get(key, defaultValue = None) of smartPy with Taquito? An instruction like:

const myContract = await Tezos.contract.at(contractAddress);
const contractStorage = await myContract.storage();
const value = await contractStorage.myMap.get(key, defaultValue = 0)

Thnak you.

1 Answer 1


As of Taquito release v6.1.0-beta.0 Taquito offers a new API for Maps which provides you with get and set calls.

The API does not offer an optional default value param, You will have to catch the error and assign your value.

We will change the behaviour of get to return undefined on the unknown key. I will update this issue when it is released. You can track Issue 298

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.