Skip to content

Commit 1cb758b

Browse files
authored
Merge pull request #1456 from OneOf-Inc/docs/tezos_ffi
DA-587 Update tezos docs (FFI section)
2 parents 0bbd97b + 326f136 commit 1cb758b

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

docs/reference/firefly_interface_format.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ The type field here is the JSON input type when making a request to FireFly to i
9595

9696
### Schema details
9797

98+
<a name="schema-details"></a>
9899
The details field is quite important in some cases. Because the `details` field is passed to the blockchain plugin, it is used to encapsulate blockchain specific type information about a particular field. Additionally, because each blockchain plugin can add rules to the list of schema requirements above, a blockchain plugin can enforce that certain fields are always present within the `details` field.
99100

100101
For example, the Ethereum plugin always needs to know what Solidity type the field is. It also defines several optional fields. A full Ethereum details field may look like:

docs/tutorials/custom_contracts/tezos.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,135 @@ Here we can see that our new contract address is `KT1ED4gj2xZnp8318yxa5NpvyvW15p
9090
As we know from the previous section - smart contracts on the Tezos blockchain are using the domain-specific, stack-based programming language called [Michelson](https://tezos.gitlab.io/active/michelson.html). It is a key component of the Tezos platform and plays a fundamental role in defining the behavior of smart contracts and facilitating their execution.
9191
This language is very efficient but also a bit tricky and challenging for learning, so in order to teach FireFly how to interact with the smart contract, we will be using [FireFly Interface (FFI)](../../reference/firefly_interface_format.md) to define the contract inteface which later will be encoded to Michelson.
9292

93+
### Schema details
94+
95+
The `details` field is used to encapsulate blockchain specific type information about a specific field. (More details at [schema details](../../reference/firefly_interface_format.md#schema-details))
96+
97+
#### Supported Tezos types
98+
99+
- nat
100+
- integer
101+
- string
102+
- address
103+
- bytes
104+
- boolean
105+
- variant
106+
- list
107+
- struct
108+
109+
#### Internal type vs Internal schema
110+
111+
<i>internalType</i> is a field which is used to describe tezos primitive types
112+
113+
``` json
114+
{
115+
"details": {
116+
"type": "address",
117+
"internalType": "address"
118+
}
119+
}
120+
```
121+
122+
<i>internalSchema</i> in turn is used to describe more complex tezos types as <b>list</b>, <b>struct</b> or <b>variant</b>
123+
124+
<i>Struct example:</i>
125+
126+
``` json
127+
{
128+
"details": {
129+
"type": "schema",
130+
"internalSchema": {
131+
"type": "struct",
132+
"args": [
133+
{
134+
"name": "metadata",
135+
"type": "bytes"
136+
},
137+
{
138+
"name": "token_id",
139+
"type": "nat"
140+
}
141+
]
142+
}
143+
}
144+
}
145+
```
146+
147+
<i>List example:</i>
148+
149+
``` json
150+
{
151+
"details": {
152+
"type": "schema",
153+
"internalSchema": {
154+
"type": "struct",
155+
"args": [
156+
{
157+
"name": "metadata",
158+
"type": "bytes"
159+
},
160+
{
161+
"name": "token_id",
162+
"type": "nat"
163+
}
164+
]
165+
}
166+
}
167+
}
168+
```
169+
170+
<i>Variant example:</i>
171+
172+
``` json
173+
{
174+
"details": {
175+
"type": "schema",
176+
"internalSchema": {
177+
"type": "variant",
178+
"variants": [
179+
"add_operator",
180+
"remove_operator"
181+
],
182+
"args": [
183+
{
184+
"type": "struct",
185+
"args": [
186+
{
187+
"name": "owner",
188+
"type": "address"
189+
},
190+
{
191+
"name": "operator",
192+
"type": "address"
193+
},
194+
{
195+
"name": "token_id",
196+
"type": "nat"
197+
}
198+
]
199+
}
200+
]
201+
}
202+
}
203+
}
204+
```
205+
206+
#### Options
207+
208+
<i>Option</i> type is used to indicate a value as optional (see more at [smartpy options](https://smartpy.io/manual/syntax/options-and-variants#options))
209+
210+
``` json
211+
{
212+
"details": {
213+
"type": "string",
214+
"internalType": "string",
215+
"kind": "option"
216+
}
217+
}
218+
```
219+
220+
### FA2 example
221+
93222
The following FFI sample demonstrates the specification for the widely used FA2 (analogue of ERC721 for EVM) smart contract:
94223

95224
```json

0 commit comments

Comments
 (0)