Add not about mappings.

This commit is contained in:
Jacques Wagener 2019-09-13 17:53:31 +02:00
parent 97d7b70c0c
commit 6f0fbcb4cc
No known key found for this signature in database
GPG Key ID: C294D1025DA0E923
1 changed files with 16 additions and 0 deletions

View File

@ -73,3 +73,19 @@ contract("Main"):
proc nameGiven(name: bytes32, address {.indexed.}: uint128) {.event.} proc nameGiven(name: bytes32, address {.indexed.}: uint128) {.event.}
``` ```
# Mappings
Nimplay uses `StorageTable` type to indicated a mapping.
```nim
contract("Registry"):
names: StorageTable[bytes32, bytes32]
proc set_name*(k: bytes32, v: bytes32) {.self.} =
self.names[k] = v
proc get_name*(k: bytes32): bytes32 {.self.} =
self.names[k]
```