Skip to content

Commit

Permalink
deploy: 1cb758b
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyer committed Feb 12, 2024
1 parent 4bca17b commit 3d1af2b
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 4 deletions.
4 changes: 2 additions & 2 deletions head/assets/js/search-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -4657,7 +4657,7 @@
},"776": {
"doc": "Tezos",
"title": "Table of contents",
"content": ". | Work with Tezos smart contracts . | Smart Contract Languages | Example smart contract | Contract deployment | The FireFly Interface Format | Broadcast the contract interface . | Request | Response | . | Create an HTTP API for the contract . | Request | Response | . | View OpenAPI spec for the contract | Invoke the smart contract . | Request | Response | . | Query the current value . | Request | Response | . | . | . ",
"content": ". | Work with Tezos smart contracts . | Smart Contract Languages | Example smart contract | Contract deployment | The FireFly Interface Format . | Schema details . | Supported Tezos types | Internal type vs Internal schema | Options | . | FA2 example | . | Broadcast the contract interface . | Request | Response | . | Create an HTTP API for the contract . | Request | Response | . | View OpenAPI spec for the contract | Invoke the smart contract . | Request | Response | . | Query the current value . | Request | Response | . | . | . ",
"url": "/firefly/head/tutorials/custom_contracts/tezos.html#table-of-contents",
"relUrl": "/tutorials/custom_contracts/tezos.html#table-of-contents"
},"777": {
Expand All @@ -4681,7 +4681,7 @@
},"780": {
"doc": "Tezos",
"title": "The FireFly Interface Format",
"content": "As we know from the previous section - smart contracts on the Tezos blockchain are using the domain-specific, stack-based programming language called Michelson. 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. 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) to define the contract inteface which later will be encoded to Michelson. The following FFI sample demonstrates the specification for the widely used FA2 (analogue of ERC721 for EVM) smart contract: . { \"namespace\": \"default\", \"name\": \"fa2\", \"version\": \"v1.0.0\", \"description\": \"\", \"methods\": [ { \"name\": \"burn\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"token_ids\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"nat\", \"internalType\": \"nat\" } } } ], \"returns\": [] }, { \"name\": \"destroy\", \"pathname\": \"\", \"description\": \"\", \"params\": [], \"returns\": [] }, { \"name\": \"mint\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"owner\", \"schema\": { \"type\": \"string\", \"details\": { \"type\": \"address\", \"internalType\": \"address\" } } }, { \"name\": \"requests\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"struct\", \"args\": [ { \"name\": \"metadata\", \"type\": \"bytes\" }, { \"name\": \"token_id\", \"type\": \"nat\" } ] } } } } ], \"returns\": [] }, { \"name\": \"pause\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"pause\", \"schema\": { \"type\": \"boolean\", \"details\": { \"type\": \"boolean\", \"internalType\": \"boolean\" } } } ], \"returns\": [] }, { \"name\": \"select\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"batch\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"struct\", \"args\": [ { \"name\": \"token_id\", \"type\": \"nat\" }, { \"name\": \"recipient\", \"type\": \"address\" }, { \"name\": \"token_id_start\", \"type\": \"nat\" }, { \"name\": \"token_id_end\", \"type\": \"nat\" } ] } } } } ], \"returns\": [] }, { \"name\": \"transfer\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"batch\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"struct\", \"args\": [ { \"name\": \"from_\", \"type\": \"address\" }, { \"name\": \"txs\", \"type\": \"list\", \"args\": [ { \"type\": \"struct\", \"args\": [ { \"name\": \"to_\", \"type\": \"address\" }, { \"name\": \"token_id\", \"type\": \"nat\" }, { \"name\": \"amount\", \"type\": \"nat\" } ] } ] } ] } } } } ], \"returns\": [] }, { \"name\": \"update_admin\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"admin\", \"schema\": { \"type\": \"string\", \"details\": { \"type\": \"address\", \"internalType\": \"address\" } } } ], \"returns\": [] }, { \"name\": \"update_operators\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"requests\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"variant\", \"variants\": [ \"add_operator\", \"remove_operator\" ], \"args\": [ { \"type\": \"struct\", \"args\": [ { \"name\": \"owner\", \"type\": \"address\" }, { \"name\": \"operator\", \"type\": \"address\" }, { \"name\": \"token_id\", \"type\": \"nat\" } ] } ] } } } } ], \"returns\": [] } ], \"events\": [] } . ",
"content": "As we know from the previous section - smart contracts on the Tezos blockchain are using the domain-specific, stack-based programming language called Michelson. 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. 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) to define the contract inteface which later will be encoded to Michelson. Schema details . The details field is used to encapsulate blockchain specific type information about a specific field. (More details at schema details) . Supported Tezos types . | nat | integer | string | address | bytes | boolean | variant | list | struct | . Internal type vs Internal schema . internalType is a field which is used to describe tezos primitive types . { \"details\": { \"type\": \"address\", \"internalType\": \"address\" } } . internalSchema in turn is used to describe more complex tezos types as list, struct or variant . Struct example: . { \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"struct\", \"args\": [ { \"name\": \"metadata\", \"type\": \"bytes\" }, { \"name\": \"token_id\", \"type\": \"nat\" } ] } } } . List example: . { \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"struct\", \"args\": [ { \"name\": \"metadata\", \"type\": \"bytes\" }, { \"name\": \"token_id\", \"type\": \"nat\" } ] } } } . Variant example: . { \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"variant\", \"variants\": [ \"add_operator\", \"remove_operator\" ], \"args\": [ { \"type\": \"struct\", \"args\": [ { \"name\": \"owner\", \"type\": \"address\" }, { \"name\": \"operator\", \"type\": \"address\" }, { \"name\": \"token_id\", \"type\": \"nat\" } ] } ] } } } . Options . Option type is used to indicate a value as optional (see more at smartpy options) . { \"details\": { \"type\": \"string\", \"internalType\": \"string\", \"kind\": \"option\" } } . FA2 example . The following FFI sample demonstrates the specification for the widely used FA2 (analogue of ERC721 for EVM) smart contract: . { \"namespace\": \"default\", \"name\": \"fa2\", \"version\": \"v1.0.0\", \"description\": \"\", \"methods\": [ { \"name\": \"burn\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"token_ids\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"nat\", \"internalType\": \"nat\" } } } ], \"returns\": [] }, { \"name\": \"destroy\", \"pathname\": \"\", \"description\": \"\", \"params\": [], \"returns\": [] }, { \"name\": \"mint\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"owner\", \"schema\": { \"type\": \"string\", \"details\": { \"type\": \"address\", \"internalType\": \"address\" } } }, { \"name\": \"requests\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"struct\", \"args\": [ { \"name\": \"metadata\", \"type\": \"bytes\" }, { \"name\": \"token_id\", \"type\": \"nat\" } ] } } } } ], \"returns\": [] }, { \"name\": \"pause\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"pause\", \"schema\": { \"type\": \"boolean\", \"details\": { \"type\": \"boolean\", \"internalType\": \"boolean\" } } } ], \"returns\": [] }, { \"name\": \"select\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"batch\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"struct\", \"args\": [ { \"name\": \"token_id\", \"type\": \"nat\" }, { \"name\": \"recipient\", \"type\": \"address\" }, { \"name\": \"token_id_start\", \"type\": \"nat\" }, { \"name\": \"token_id_end\", \"type\": \"nat\" } ] } } } } ], \"returns\": [] }, { \"name\": \"transfer\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"batch\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"struct\", \"args\": [ { \"name\": \"from_\", \"type\": \"address\" }, { \"name\": \"txs\", \"type\": \"list\", \"args\": [ { \"type\": \"struct\", \"args\": [ { \"name\": \"to_\", \"type\": \"address\" }, { \"name\": \"token_id\", \"type\": \"nat\" }, { \"name\": \"amount\", \"type\": \"nat\" } ] } ] } ] } } } } ], \"returns\": [] }, { \"name\": \"update_admin\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"admin\", \"schema\": { \"type\": \"string\", \"details\": { \"type\": \"address\", \"internalType\": \"address\" } } } ], \"returns\": [] }, { \"name\": \"update_operators\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"requests\", \"schema\": { \"type\": \"array\", \"details\": { \"type\": \"schema\", \"internalSchema\": { \"type\": \"variant\", \"variants\": [ \"add_operator\", \"remove_operator\" ], \"args\": [ { \"type\": \"struct\", \"args\": [ { \"name\": \"owner\", \"type\": \"address\" }, { \"name\": \"operator\", \"type\": \"address\" }, { \"name\": \"token_id\", \"type\": \"nat\" } ] } ] } } } } ], \"returns\": [] } ], \"events\": [] } . ",
"url": "/firefly/head/tutorials/custom_contracts/tezos.html#the-firefly-interface-format",
"relUrl": "/tutorials/custom_contracts/tezos.html#the-firefly-interface-format"
},"781": {
Expand Down
3 changes: 2 additions & 1 deletion head/reference/firefly_interface_format.html
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ <h3 id="schema-details">
</h3>


<p>The details field is quite important in some cases. Because the <code class="language-plaintext highlighter-rouge">details</code> 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 <code class="language-plaintext highlighter-rouge">details</code> field.</p>
<p><a name="schema-details"></a>
The details field is quite important in some cases. Because the <code class="language-plaintext highlighter-rouge">details</code> 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 <code class="language-plaintext highlighter-rouge">details</code> field.</p>

<p>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:</p>

Expand Down
Loading

0 comments on commit 3d1af2b

Please sign in to comment.