I'm trying to learn how to write a smart contract and using Ligo. I'm struggling with quite a few things at the same time e.g. syntax, understand the documentation, best practices etc.

Baby step is, register a user profile i.e. an ipfs hash. So storing this as a map, with the sender being the key and the hash being the value:

type artist is address
type ipfsProfileAddress is string

type artists is map (artist, ipfsProfileAddress)
const artists_storage : artists = map []

// get current address store as artist key and save ipfsProfileAddress
function register_artist (const profile: ipfsProfileAddress) : ipfsProfileAddress is block {
  artists_storage(Tezos.sender, profile)
} with profile

Do I need to instantiate the map first? i.e. create the type, then create an empty one?

How do you set a key -> value?


1 Answer 1


As far as I know, you have to create the default storage for your contract when you deploy it and that's when you will instantiate your storage (and your empty map), so I don't think it is necessary to instantiate it in the contract. Did you try to compile the contract with the instantiated empty map?

I use ReasonLigo more than PascalLigo, but the docs indicate the following way to update a map: artists_storage [(artist: artist)] := ipfsProfileAddress.

  • Thanks for replying. Looks good. I did realise however that with maps the key needs to be the same type as the value so I guess I would have to use a record. I'm parking this for now, going to use Ethereum/solidity for proof of concept first as I've used that before Commented Mar 15, 2020 at 18:40
  • You can choose a different type for the key and the value, unless you mean that the type of the key or value has to change at some point, in which case you should better use a record. Try ReasonLigo, the syntax is a lot friendlier if you know Solidity already ;) Commented Mar 15, 2020 at 20:49
  • Thanks @claudebarde I've started using CameLIGO and I find it much easier to use than Pascal. I'm nearly there, I just created a new issue as I'm still struggling Commented Mar 20, 2020 at 11:53

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.