Skip to content

Commit

Permalink
deploy: e0e9e34
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyer committed Nov 15, 2023
1 parent f9218d4 commit f33e6b9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
14 changes: 7 additions & 7 deletions head/assets/js/search-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -4663,7 +4663,7 @@
},"777": {
"doc": "Tezos",
"title": "Example smart contract",
"content": "First let’s look at a simple contract smart contract called SimpleStorage, which we will be using on a Tezos blockchain. Here we have one state variable called ‘storedValue’ and initialized with the value 12. During initialization the type of the variable was defined as ‘int’. You can see more at SmartPy types. And then we added a simple test, which set the storage value to 15 and checks that the value was changed as expected. NOTE: Tests are used to verify the validity of contract entrypoints and do not affect the state of the contract during deployment. Here is the source for this contract: . import smartpy as sp @sp.module def main(): class SimpleStorage(sp.Contract): def __init__(self, value): self.data.storedValue = value @sp.entrypoint def replace(self, params): self.data.storedValue = params.value @sp.add_test(name=\"SimpleStorage\") def test(): c1 = main.SimpleStorage(12) scenario = sp.test_scenario(main) scenario.h1(\"SimpleStorage\") scenario += c1 c1.replace(value=15) scenario.verify(c1.data.storedValue == 15) . ",
"content": "First let’s look at a simple contract smart contract called SimpleStorage, which we will be using on a Tezos blockchain. Here we have one state variable called ‘storedValue’ and initialized with the value 12. During initialization the type of the variable was defined as ‘int’. You can see more at SmartPy types. And then we added a simple test, which set the storage value to 15 and checks that the value was changed as expected. NOTE: Smart contract’s tests (marked with @sp.add_test annotation) are used to verify the validity of contract entrypoints and do not affect the state of the contract during deployment. Here is the source for this contract: . import smartpy as sp @sp.module def main(): class SimpleStorage(sp.Contract): def __init__(self, value): self.data.storedValue = value @sp.entrypoint def replace(self, params): self.data.storedValue = params.value @sp.add_test(name=\"SimpleStorage\") def test(): c1 = main.SimpleStorage(12) scenario = sp.test_scenario(main) scenario.h1(\"SimpleStorage\") scenario += c1 c1.replace(value=15) scenario.verify(c1.data.storedValue == 15) . ",
"url": "/firefly/head/tutorials/custom_contracts/tezos.html#example-smart-contract",
"relUrl": "/tutorials/custom_contracts/tezos.html#example-smart-contract"
},"778": {
Expand Down Expand Up @@ -4699,7 +4699,7 @@
},"783": {
"doc": "Tezos",
"title": "Invoke the smart contract",
"content": "Now that we’ve got everything set up, it’s time to use our smart contract! We’re going to make a POST request to the invoke/replace endpoint to set the integer value on-chain. Let’s set it to the value of 3 right now. Request . POST http://localhost:5000/api/v1/namespaces/default/apis/simple-storage/invoke/replace . { \"input\": { \"newValue\": 3 }, \"key\": \"tz1cuFw1E2Mn2bVS8q8d7QoCb6FXC18JivSp\" } . NOTE: The key field is the Tezos account address, which will be used for signing our transactions. See more at transaction signing service set up. Response . { \"id\": \"cb38a538-7093-4150-8a80-6097a666df82\", \"namespace\": \"default\", \"tx\": \"5860befb-9f76-4aa0-a67c-55718b2c46d6\", \"type\": \"blockchain_invoke\", \"status\": \"Pending\", \"plugin\": \"tezos\", \"input\": { \"input\": { \"newValue\": 3 }, \"interface\": \"c655704a-f0e2-4aa3-adbb-c7bf3280cdc2\", \"key\": \"tz1cuFw1E2Mn2bVS8q8d7QoCb6FXC18JivSp\", \"location\": { \"address\": \"KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s\" }, \"method\": { \"description\": \"\", \"id\": \"6f707105-d8b5-4808-a864-51475086608d\", \"interface\": \"c655704a-f0e2-4aa3-adbb-c7bf3280cdc2\", \"name\": \"replace\", \"namespace\": \"default\", \"params\": [ { \"name\": \"newValue\", \"schema\": { \"details\": { \"internalType\": \"integer\", \"type\": \"integer\" }, \"type\": \"integer\" } } ], \"pathname\": \"replace\", \"returns\": [] }, \"methodPath\": \"replace\", \"options\": null, \"type\": \"invoke\" }, \"created\": \"2023-09-27T09:12:24.033724927Z\", \"updated\": \"2023-09-27T09:12:24.033724927Z\" } . You’ll notice that we got an ID back with status Pending, and that’s expected due to the asynchronous programming model of working with custom onchain logic in FireFly. After a while, let’s see the result of our operation. ",
"content": "Now that we’ve got everything set up, it’s time to use our smart contract! We’re going to make a POST request to the invoke/replace endpoint to set the integer value on-chain. Let’s set it to the value of 3 right now. Request . POST http://localhost:5000/api/v1/namespaces/default/apis/simple-storage/invoke/replace . { \"input\": { \"newValue\": 3 }, \"key\": \"tz1cuFw1E2Mn2bVS8q8d7QoCb6FXC18JivSp\" } . NOTE: The key field (optional) is the tezos account’s address, which is used to sign blockchain transactions. See more at transaction signing service set up. Response . { \"id\": \"cb38a538-7093-4150-8a80-6097a666df82\", \"namespace\": \"default\", \"tx\": \"5860befb-9f76-4aa0-a67c-55718b2c46d6\", \"type\": \"blockchain_invoke\", \"status\": \"Pending\", \"plugin\": \"tezos\", \"input\": { \"input\": { \"newValue\": 3 }, \"interface\": \"c655704a-f0e2-4aa3-adbb-c7bf3280cdc2\", \"key\": \"tz1cuFw1E2Mn2bVS8q8d7QoCb6FXC18JivSp\", \"location\": { \"address\": \"KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s\" }, \"method\": { \"description\": \"\", \"id\": \"6f707105-d8b5-4808-a864-51475086608d\", \"interface\": \"c655704a-f0e2-4aa3-adbb-c7bf3280cdc2\", \"name\": \"replace\", \"namespace\": \"default\", \"params\": [ { \"name\": \"newValue\", \"schema\": { \"details\": { \"internalType\": \"integer\", \"type\": \"integer\" }, \"type\": \"integer\" } } ], \"pathname\": \"replace\", \"returns\": [] }, \"methodPath\": \"replace\", \"options\": null, \"type\": \"invoke\" }, \"created\": \"2023-09-27T09:12:24.033724927Z\", \"updated\": \"2023-09-27T09:12:24.033724927Z\" } . You’ll notice that we got an ID back with status Pending, and that’s expected due to the asynchronous programming model of working with custom onchain logic in FireFly. After a while, let’s see the result of our operation. ",
"url": "/firefly/head/tutorials/custom_contracts/tezos.html#invoke-the-smart-contract",
"relUrl": "/tutorials/custom_contracts/tezos.html#invoke-the-smart-contract"
},"784": {
Expand Down Expand Up @@ -4729,31 +4729,31 @@
},"788": {
"doc": "pages.tezos_testnet",
"title": "Set up the transaction signing service ",
"content": "Signatory service allows to work with many different key-management systems. You should choose and set up an appropriate one. For development/prototyping purposes the easiest way is to use the local signing option. Note: Tezos accounts (private/public keys) should be generated by chosen KMS. ",
"content": "Signatory service allows to work with many different key-management systems. By default, FF uses local signing option. However, it is also possible to configure the transaction signing service using key management systems such as: AWS/Google/Azure KMS, HCP Vault, etc. NOTE: The default option is not secure and is mainly used for development and demo purposes. Therefore, for the production, use the selected KMS. The full list can be found here. ",
"url": "/firefly/head/tutorials/chains/tezos_testnet.html#set-up-the-transaction-signing-service-",
"relUrl": "/tutorials/chains/tezos_testnet.html#set-up-the-transaction-signing-service-"
},"789": {
"doc": "pages.tezos_testnet",
"title": "Create a tezosconnect.yml config file",
"content": "In order to connect to the Tezos testnet, you will need to set a few configuration options for the tezosconnect blockchain connector. Create a text file called tezosconnect.yml with the following contents: . connector: blockchain: rpc: https://rpc.ghost.tzstats.com network: ghostnet signatory: http://127.0.0.1:6732 # tx signing service address . For this tutorial, we will assume this file is saved at ~/Desktop/tezosconnect.yml. If your path is different, you will need to adjust the path in the next command below. ",
"content": "In order to connect to the Tezos testnet, you will need to set a few configuration options for the tezosconnect blockchain connector. Create a text file called tezosconnect.yml with the following contents: . connector: blockchain: rpc: https://ghostnet.ecadinfra.com network: ghostnet signatory: http://127.0.0.1:6732 # tx signing service address . For this tutorial, we will assume this file is saved at ~/Desktop/tezosconnect.yml. If your path is different, you will need to adjust the path in the next command below. ",
"url": "/firefly/head/tutorials/chains/tezos_testnet.html#create-a-tezosconnectyml-config-file",
"relUrl": "/tutorials/chains/tezos_testnet.html#create-a-tezosconnectyml-config-file"
},"790": {
"doc": "pages.tezos_testnet",
"title": "Creating a new stack",
"content": "To create a local FireFly development stack and connect it to the Tezos Ghostnet testnet, we will use command line flags to customize the following settings: . | Create a new Tezos based stack named tezos with 1 member | Disable multiparty mode. We are going to be using this FireFly node as a Web3 gateway, and we don’t need to communicate with a consortium here | Merge the custom config created above with the generated tezosconnect.yml config file | . To do this, run the following command: . ff init ethereum tezos 1 \\ --multiparty=false \\ --connector-config ~/Desktop/tezosonnect.yml . ",
"content": "To create a local FireFly development stack and connect it to the Tezos Ghostnet testnet, we will use command line flags to customize the following settings: . | Create a new Tezos based stack named tezos with 1 member | Disable multiparty mode. We are going to be using this FireFly node as a Web3 gateway, and we don’t need to communicate with a consortium here | Merge the custom config created above with the generated tezosconnect.yml config file | . To do this, run the following command: . ff init tezos dev 1 \\ --multiparty=false \\ --connector-config ~/Desktop/tezosonnect.yml . ",
"url": "/firefly/head/tutorials/chains/tezos_testnet.html#creating-a-new-stack",
"relUrl": "/tutorials/chains/tezos_testnet.html#creating-a-new-stack"
},"791": {
"doc": "pages.tezos_testnet",
"title": "Start the stack",
"content": "Now you should be able to start your stack by running: . ff start tezos . After some time it should print out the following: . Web UI for member '0': http://127.0.0.1:5000/ui Sandbox UI for member '0': http://127.0.0.1:5109 To see logs for your stack run: ff logs tezos . ",
"content": "Now you should be able to start your stack by running: . ff start dev . After some time it should print out the following: . Web UI for member '0': http://127.0.0.1:5000/ui Sandbox UI for member '0': http://127.0.0.1:5109 To see logs for your stack run: ff logs dev . ",
"url": "/firefly/head/tutorials/chains/tezos_testnet.html#start-the-stack",
"relUrl": "/tutorials/chains/tezos_testnet.html#start-the-stack"
},"792": {
"doc": "pages.tezos_testnet",
"title": "Get some XTZ",
"content": "At this point you should have a working FireFly stack, talking to a public chain. However, you won’t be able to run any transactions just yet, because you don’t have any way to pay transaction fee. A testnet faucet can give us some XTZ, the native token for Tezos. First, you need to get an account address, which was created during signer set up step. After that, go to Tezos Ghostnet Faucet and paste the address in the form and click the Request button. Confirm the transaction on TzStats . You should be able to go lookup your account on TzStats for the Ghostnet testnet and see that you now have a balance of 100 XTZ (or 2001 XTZ accordingly). Simply paste in your account address to search for it. On the Transfers tab from you account page you will see the actual transfer of the XTZ from the faucet. ",
"content": "At this point you should have a working FireFly stack, talking to a public chain. However, you won’t be able to run any transactions just yet, because you don’t have any way to pay transaction fee. A testnet faucet can give us some XTZ, the native token for Tezos. First, you need to get an account address, which was created during signer set up step. To check that, you can run: . ff accounts list dev [ { \"address\": \"tz1cuFw1E2Mn2bVS8q8d7QoCb6FXC18JivSp\", \"privateKey\": \"...\" } ] . After that, go to Tezos Ghostnet Faucet and paste the address in the form and click the Request button. Confirm the transaction on TzStats . You should be able to go lookup your account on TzStats for the Ghostnet testnet and see that you now have a balance of 100 XTZ (or 2001 XTZ accordingly). Simply paste in your account address to search for it. On the Transfers tab from you account page you will see the actual transfer of the XTZ from the faucet. ",
"url": "/firefly/head/tutorials/chains/tezos_testnet.html#get-some-xtz",
"relUrl": "/tutorials/chains/tezos_testnet.html#get-some-xtz"
},"793": {
Expand Down
30 changes: 21 additions & 9 deletions head/tutorials/chains/tezos_testnet.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,13 @@ <h2 id="set-up-the-transaction-signing-service-">
</h2>


<p><a href="https://signatory.io/">Signatory</a> service allows to work with many different key-management systems.
You should choose and set up an appropriate one.
For development/prototyping purposes the easiest way is to use the <a href="https://signatory.io/docs/file_based">local signing</a> option.
Note: Tezos accounts (private/public keys) should be generated by chosen KMS.</p>
<p><a href="https://signatory.io/">Signatory</a> service allows to work with many different key-management systems.<br />
By default, FF uses <a href="https://signatory.io/docs/file_based">local signing</a> option.<br />
However, it is also possible to configure the transaction signing service using key management systems such as: AWS/Google/Azure KMS, HCP Vault, etc.</p>
<blockquote>
<p><strong>NOTE</strong>: The default option is not secure and is mainly used for development and demo purposes. Therefore, for the production, use the selected KMS.<br />
The full list can be found <a href="https://github.com/ecadlabs/signatory#backend-kmshsm-support-status">here</a>.</p>
</blockquote>
<h2 id="create-a-tezosconnectyml-config-file">


Expand All @@ -343,7 +346,7 @@ <h2 id="create-a-tezosconnectyml-config-file">

<div class="language-yml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">connector</span><span class="pi">:</span>
<span class="na">blockchain</span><span class="pi">:</span>
<span class="na">rpc</span><span class="pi">:</span> <span class="s">https://rpc.ghost.tzstats.com</span>
<span class="na">rpc</span><span class="pi">:</span> <span class="s">https://ghostnet.ecadinfra.com</span>
<span class="na">network</span><span class="pi">:</span> <span class="s">ghostnet</span>
<span class="na">signatory</span><span class="pi">:</span> <span class="s">http://127.0.0.1:6732</span> <span class="c1"># tx signing service address</span>
</code></pre></div></div>
Expand All @@ -368,7 +371,7 @@ <h2 id="creating-a-new-stack">

<p>To do this, run the following command:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ff init ethereum tezos 1 \
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ff init tezos dev 1 \
--multiparty=false \
--connector-config ~/Desktop/tezosonnect.yml
</code></pre></div></div>
Expand All @@ -383,7 +386,7 @@ <h2 id="start-the-stack">

<p>Now you should be able to start your stack by running:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ff start tezos
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ff start dev
</code></pre></div></div>

<p>After some time it should print out the following:</p>
Expand All @@ -394,7 +397,7 @@ <h2 id="start-the-stack">

To see logs for your stack run:

ff logs tezos
ff logs dev
</code></pre></div></div>
<h2 id="get-some-xtz">

Expand All @@ -407,7 +410,16 @@ <h2 id="get-some-xtz">

<p>At this point you should have a working FireFly stack, talking to a public chain. However, you won’t be able to run any transactions just yet, because you don’t have any way to pay transaction fee. A testnet faucet can give us some XTZ, the native token for Tezos.</p>

<p>First, you need to get an account address, which was created during <a href="#signatory">signer set up</a> step.</p>
<p>First, you need to get an account address, which was created during <a href="#signatory">signer set up</a> step.<br />
To check that, you can run:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ff accounts list dev
[
{
"address": "tz1cuFw1E2Mn2bVS8q8d7QoCb6FXC18JivSp",
"privateKey": "..."
}
]
</code></pre></div></div>

<p>After that, go to <a href="https://faucet.ghostnet.teztnets.xyz/">Tezos Ghostnet Faucet</a> and paste the address in the form and click the <strong>Request</strong> button.</p>

Expand Down
4 changes: 2 additions & 2 deletions head/tutorials/custom_contracts/tezos.html
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ <h2 id="example-smart-contract">
<p>First let’s look at a simple contract smart contract called <code class="language-plaintext highlighter-rouge">SimpleStorage</code>, which we will be using on a Tezos blockchain. Here we have one state variable called ‘storedValue’ and initialized with the value 12. During initialization the type of the variable was defined as ‘int’. You can see more at <a href="https://smartpy.io/manual/syntax/integers-and-mutez">SmartPy types</a>. And then we added a simple test, which set the storage value to 15 and checks that the value was changed as expected.</p>

<blockquote>
<p><strong>NOTE:</strong> Tests are used to verify the validity of contract entrypoints and do not affect the state of the contract during deployment.</p>
<p><strong>NOTE:</strong> Smart contract’s tests (marked with <code class="language-plaintext highlighter-rouge">@sp.add_test</code> annotation) are used to verify the validity of contract entrypoints and do not affect the state of the contract during deployment.</p>
</blockquote>

<p>Here is the source for this contract:</p>
Expand Down Expand Up @@ -872,7 +872,7 @@ <h3 id="request-2">
</span></code></pre></div></div>

<blockquote>
<p><strong>NOTE</strong>: The <code class="language-plaintext highlighter-rouge">key</code> field is the Tezos account address, which will be used for signing our transactions.
<p><strong>NOTE</strong>: The <code class="language-plaintext highlighter-rouge">key</code> field (optional) is the tezos account’s address, which is used to sign blockchain transactions.<br />
See more at <a href="/firefly/head/tutorials/chains/tezos_testnet.html#signatory">transaction signing service set up</a>.</p>
</blockquote>
<h3 id="response-2">
Expand Down

0 comments on commit f33e6b9

Please sign in to comment.