Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/czyczk/exp-ink-struct

ink! contract experiment. Dealing with structs.
https://github.com/czyczk/exp-ink-struct

Last synced: 3 months ago
JSON representation

ink! contract experiment. Dealing with structs.

Awesome Lists containing this project

README

        

# Experiment of ink! Smart Contract: Struct

This example smart contract is for testing purpose.

- Nested structs as parameter (`Inner`, `Outer`): Normal nested JSON object passed in through the API.
- Enum as parameter (`Shape::Circle`, `Shape::Rectangle`): Take `Shape::Rectangle` as example:

```
[
{
"Rectangle": [
3,
4
]
}
]
```

or

```
[
{
"Rectangle": {
"x": 3,
"y": 4
}
}
]
```

**Explanation:** Specify the name of the enum variant in the JSON object's top-level entry. Then either pass in the fields in order or name the fields and specify the values in any order.