diff --git a/head/assets/js/search-data.json b/head/assets/js/search-data.json index 03b7f7b328..c79ca52430 100644 --- a/head/assets/js/search-data.json +++ b/head/assets/js/search-data.json @@ -4651,7 +4651,7 @@ },"775": { "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 | . | Get the operation result . | Request | Response | . | . | . ", + "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 | . | . | . ", "url": "/firefly/head/tutorials/custom_contracts/tezos.html#table-of-contents", "relUrl": "/tutorials/custom_contracts/tezos.html#table-of-contents" },"776": { @@ -4663,13 +4663,13 @@ },"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: 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) . ", + "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(): # Declares a new contract class SimpleStorage(sp.Contract): # Storage. Persists in between transactions def __init__(self, value): self.data.x = value # Allows the stored integer to be changed @sp.entrypoint def set(self, params): self.data.x = params.value # Returns the currently stored integer @sp.onchain_view() def get(self): return self.data.x @sp.add_test(name=\"SimpleStorage\") def test(): # Initialize the contract c = main.SimpleStorage(12) # Create a test scenario and run some test cases scenario = sp.test_scenario(main) scenario.h1(\"SimpleStorage\") scenario += c c.set(value=15) scenario.verify(c.data.x == 15) scenario.verify(scenario.compute(c.get()) == 15) . ", "url": "/firefly/head/tutorials/custom_contracts/tezos.html#example-smart-contract", "relUrl": "/tutorials/custom_contracts/tezos.html#example-smart-contract" },"778": { "doc": "Tezos", "title": "Contract deployment", - "content": "To deploy the contract, we will use SmartPy IDE. | Open an IDE; | Paste the contract code; | Click “Run code” button; | Then you will see “Deploy Michelson Contract” button, click on that; | Choose the Ghostnet network; | Select an account, which you’re going to use to deploy the contract; | Click “Estimate Cost From RPC” button; | Click “Deploy Contract” button; | . Here we can see that our new contract address is KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s. This is the address that we will reference in the rest of this guide. ", + "content": "To deploy the contract, we will use SmartPy IDE. | Open an IDE; | Paste the contract code; | Click “Run code” button; | Then you will see “Deploy Michelson Contract” button, click on that; | Choose the Ghostnet network; | Select an account, which you’re going to use to deploy the contract; | Click “Estimate Cost From RPC” button; | Click “Deploy Contract” button; | . Here we can see that our new contract address is KT1ED4gj2xZnp8318yxa5NpvyvW15pqe4yFg. This is the address that we will reference in the rest of this guide. ", "url": "/firefly/head/tutorials/custom_contracts/tezos.html#contract-deployment", "relUrl": "/tutorials/custom_contracts/tezos.html#contract-deployment" },"779": { @@ -4681,13 +4681,13 @@ },"780": { "doc": "Tezos", "title": "Broadcast the contract interface", - "content": "Now that we have a FireFly Interface representation of our smart contract, we want to broadcast that to the entire network. This broadcast will be pinned to the blockchain, so we can always refer to this specific name and version, and everyone in the network will know exactly which contract interface we are talking about. We will use the FFI JSON constructed above and POST that to the /contracts/interfaces API endpoint. Request . POST http://localhost:5000/api/v1/namespaces/default/contracts/interfaces . { \"namespace\": \"default\", \"name\": \"simplestorage\", \"version\": \"v1.0.0\", \"description\": \"\", \"methods\": [ { \"name\": \"replace\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"newValue\", \"schema\": { \"type\": \"integer\", \"details\": { \"type\": \"integer\", \"internalType\": \"integer\" } } } ], \"returns\": [] } ], \"events\": [] } . Response . { \"id\": \"c655704a-f0e2-4aa3-adbb-c7bf3280cdc2\", \"namespace\": \"default\", \"name\": \"simplestorage\", \"description\": \"\", \"version\": \"v1.0.0\", \"methods\": [ { \"id\": \"6f707105-d8b5-4808-a864-51475086608d\", \"interface\": \"c655704a-f0e2-4aa3-adbb-c7bf3280cdc2\", \"name\": \"replace\", \"namespace\": \"default\", \"pathname\": \"replace\", \"description\": \"\", \"params\": [ { \"name\": \"newValue\", \"schema\": { \"type\": \"integer\", \"details\": { \"type\": \"integer\", \"internalType\": \"integer\" } } } ], \"returns\": [] } ] } . NOTE: We can broadcast this contract interface conveniently with the help of FireFly Sandbox running at http://127.0.0.1:5108 . | Go to the Contracts Section | Click on Define a Contract Interface | Select FFI - FireFly Interface in the Interface Fromat dropdown | Copy the FFI JSON crafted by you into the Schema Field | Click on Run | . ", + "content": "Now that we have a FireFly Interface representation of our smart contract, we want to broadcast that to the entire network. This broadcast will be pinned to the blockchain, so we can always refer to this specific name and version, and everyone in the network will know exactly which contract interface we are talking about. We will use the FFI JSON constructed above and POST that to the /contracts/interfaces API endpoint. Request . POST http://localhost:5000/api/v1/namespaces/default/contracts/interfaces . { \"namespace\": \"default\", \"name\": \"simplestorage\", \"version\": \"v1.0.0\", \"description\": \"\", \"methods\": [ { \"name\": \"set\", \"pathname\": \"\", \"description\": \"\", \"params\": [ { \"name\": \"newValue\", \"schema\": { \"type\": \"integer\", \"details\": { \"type\": \"integer\", \"internalType\": \"integer\" } } } ], \"returns\": [] }, { \"name\": \"get\", \"pathname\": \"\", \"description\": \"\", \"params\": [], \"returns\": [] } ], \"events\": [] } . Response . { \"id\": \"f9e34787-e634-46cd-af47-b52c537404ff\", \"namespace\": \"default\", \"name\": \"simplestorage\", \"description\": \"\", \"version\": \"v1.0.0\", \"methods\": [ { \"id\": \"78f13a7f-7b85-47c3-bf51-346a9858c027\", \"interface\": \"f9e34787-e634-46cd-af47-b52c537404ff\", \"name\": \"set\", \"namespace\": \"default\", \"pathname\": \"set\", \"description\": \"\", \"params\": [ { \"name\": \"newValue\", \"schema\": { \"type\": \"integer\", \"details\": { \"type\": \"integer\", \"internalType\": \"integer\" } } } ], \"returns\": [] }, { \"id\": \"ee864e25-c3f7-42d3-aefd-a82f753e9002\", \"interface\": \"f9e34787-e634-46cd-af47-b52c537404ff\", \"name\": \"get\", \"namespace\": \"tezos\", \"pathname\": \"get\", \"description\": \"\", \"params\": [], \"returns\": [] } ] } . NOTE: We can broadcast this contract interface conveniently with the help of FireFly Sandbox running at http://127.0.0.1:5108 . | Go to the Contracts Section | Click on Define a Contract Interface | Select FFI - FireFly Interface in the Interface Fromat dropdown | Copy the FFI JSON crafted by you into the Schema Field | Click on Run | . ", "url": "/firefly/head/tutorials/custom_contracts/tezos.html#broadcast-the-contract-interface", "relUrl": "/tutorials/custom_contracts/tezos.html#broadcast-the-contract-interface" },"781": { "doc": "Tezos", "title": "Create an HTTP API for the contract", - "content": "Now comes the fun part where we see some of the powerful, developer-friendly features of FireFly. The next thing we’re going to do is tell FireFly to build an HTTP API for this smart contract, complete with an OpenAPI Specification and Swagger UI. As part of this, we’ll also tell FireFly where the contract is on the blockchain. Like the interface broadcast above, this will also generate a broadcast which will be pinned to the blockchain so all the members of the network will be aware of and able to interact with this API. We need to copy the id field we got in the response from the previous step to the interface.id field in the request body below. We will also pick a name that will be part of the URL for our HTTP API, so be sure to pick a name that is URL friendly. In this case we’ll call it simple-storage. Lastly, in the location.address field, we’re telling FireFly where an instance of the contract is deployed on-chain. NOTE: The location field is optional here, but if it is omitted, it will be required in every request to invoke or query the contract. This can be useful if you have multiple instances of the same contract deployed to different addresses. Request . POST http://localhost:5000/api/v1/namespaces/default/apis . { \"name\": \"simple-storage\", \"interface\": { \"id\": \"c655704a-f0e2-4aa3-adbb-c7bf3280cdc2\" }, \"location\": { \"address\": \"KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s\" } } . Response . { \"id\": \"af09de97-741d-4f61-8d30-4db5e7460f76\", \"namespace\": \"default\", \"interface\": { \"id\": \"c655704a-f0e2-4aa3-adbb-c7bf3280cdc2\" }, \"location\": { \"address\": \"KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s\" }, \"name\": \"simple-storage\", \"urls\": { \"openapi\": \"http://127.0.0.1:5000/api/v1/namespaces/default/apis/simple-storage/api/swagger.json\", \"ui\": \"http://127.0.0.1:5000/api/v1/namespaces/default/apis/simple-storage/api\" } } . ", + "content": "Now comes the fun part where we see some of the powerful, developer-friendly features of FireFly. The next thing we’re going to do is tell FireFly to build an HTTP API for this smart contract, complete with an OpenAPI Specification and Swagger UI. As part of this, we’ll also tell FireFly where the contract is on the blockchain. Like the interface broadcast above, this will also generate a broadcast which will be pinned to the blockchain so all the members of the network will be aware of and able to interact with this API. We need to copy the id field we got in the response from the previous step to the interface.id field in the request body below. We will also pick a name that will be part of the URL for our HTTP API, so be sure to pick a name that is URL friendly. In this case we’ll call it simple-storage. Lastly, in the location.address field, we’re telling FireFly where an instance of the contract is deployed on-chain. NOTE: The location field is optional here, but if it is omitted, it will be required in every request to invoke or query the contract. This can be useful if you have multiple instances of the same contract deployed to different addresses. Request . POST http://localhost:5000/api/v1/namespaces/default/apis . { \"name\": \"simple-storage\", \"interface\": { \"id\": \"f9e34787-e634-46cd-af47-b52c537404ff\" }, \"location\": { \"address\": \"KT1ED4gj2xZnp8318yxa5NpvyvW15pqe4yFg\" } } . Response . { \"id\": \"af09de97-741d-4f61-8d30-4db5e7460f76\", \"namespace\": \"default\", \"interface\": { \"id\": \"f9e34787-e634-46cd-af47-b52c537404ff\" }, \"location\": { \"address\": \"KT1ED4gj2xZnp8318yxa5NpvyvW15pqe4yFg\" }, \"name\": \"simple-storage\", \"urls\": { \"openapi\": \"http://127.0.0.1:5000/api/v1/namespaces/default/apis/simple-storage/api/swagger.json\", \"ui\": \"http://127.0.0.1:5000/api/v1/namespaces/default/apis/simple-storage/api\" } } . ", "url": "/firefly/head/tutorials/custom_contracts/tezos.html#create-an-http-api-for-the-contract", "relUrl": "/tutorials/custom_contracts/tezos.html#create-an-http-api-for-the-contract" },"782": { @@ -4699,15 +4699,15 @@ },"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 (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. ", + "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/set 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/set . { \"input\": { \"newValue\": 3 } } . Response . { \"id\": \"87c7ee1b-33d1-46e2-b3f5-8566c14367cf\", \"type\": \"blockchain_invoke\", \"status\": \"Pending\", \"...\" } . 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 smart contracts in FireFly. To see what the value is now, we can query the smart contract. ", "url": "/firefly/head/tutorials/custom_contracts/tezos.html#invoke-the-smart-contract", "relUrl": "/tutorials/custom_contracts/tezos.html#invoke-the-smart-contract" },"784": { "doc": "Tezos", - "title": "Get the operation result", - "content": "To see the result of the operation, call /operations endpoint with the operation ID from the previous step. Request . GET http://localhost:5000/api/v1/operations/cb38a538-7093-4150-8a80-6097a666df82?fetchstatus=true . Response . { \"id\": \"cb38a538-7093-4150-8a80-6097a666df82\", \"namespace\": \"default\", \"tx\": \"5860befb-9f76-4aa0-a67c-55718b2c46d6\", \"type\": \"blockchain_invoke\", \"status\": \"Succeeded\", \"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\" }, \"output\": { \"contractLocation\": { \"address\": \"KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s\" }, \"headers\": { \"requestId\": \"default:cb38a538-7093-4150-8a80-6097a666df82\", \"type\": \"TransactionSuccess\" }, \"protocolId\": \"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf\", \"transactionHash\": \"opMjGX58akxboipsxMcTv5yc5M4Y2ZCGktos4E26zgEpgtHop7g\" }, \"detail\": { \"receipt\": { \"blockHash\": \"BLy9BdEjBvHvhYkt8tR4wTQzHagCUmweh8K8uM6X5gXzPLbCmzP\", \"blockNumber\": \"4012016\", \"contractLocation\": { \"address\": \"KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s\" }, \"extraInfo\": [ { \"consumedGas\": \"1279\", \"contractAddress\": \"KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s\", \"counter\": \"18602183\", \"errorMessage\": null, \"fee\": \"404\", \"from\": \"tz1cuFw1E2Mn2bVS8q8d7QoCb6FXC18JivSp\", \"gasLimit\": \"1380\", \"paidStorageSizeDiff\": \"0\", \"status\": \"applied\", \"storage\": \"3\", \"to\": \"KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s\" } ], \"protocolId\": \"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf\", \"success\": true, \"transactionIndex\": \"0\" }, \"status\": \"Succeeded\" } } . Here we can see detail.receipt.extraInfo.storage section, which displays the latest state of the contract storage state after invoking the operation and that the value of the storage variable was changed to 3. ", - "url": "/firefly/head/tutorials/custom_contracts/tezos.html#get-the-operation-result", - "relUrl": "/tutorials/custom_contracts/tezos.html#get-the-operation-result" + "title": "Query the current value", + "content": "To make a read-only request to the blockchain to check the current value of the stored integer, we can make a POST to the query/get endpoint. Request . POST http://localhost:5000/api/v1/namespaces/default/apis/simple-storage/query/get . {} . Response . { \"3\" } . NOTE: Some contracts may have queries that require input parameters. That’s why the query endpoint is a POST, rather than a GET so that parameters can be passed as JSON in the request body. This particular function does not have any parameters, so we just pass an empty JSON object. ", + "url": "/firefly/head/tutorials/custom_contracts/tezos.html#query-the-current-value", + "relUrl": "/tutorials/custom_contracts/tezos.html#query-the-current-value" },"785": { "doc": "Tezos", "title": "Tezos", @@ -4717,7 +4717,7 @@ },"786": { "doc": "pages.tezos_testnet", "title": "Tezos Testnet", - "content": ". | Previous steps: Install the FireFly CLI | Set up the transaction signing service | Create a tezosconnect.yml config file | Creating a new stack | Start the stack | Get some XTZ . | Confirm the transaction on TzStats | . | . This guide will walk you through the steps to create a local FireFly development environment and connect it to the public Tezos Ghostnet testnet. ", + "content": ". | Previous steps: Install the FireFly CLI | Set up the transaction signing service | Creating a new stack | Start the stack | Get some XTZ . | Confirm the transaction on TzStats | . | Use the public testnet | . This guide will walk you through the steps to create a local FireFly development environment and connect it to the public Tezos Ghostnet testnet. ", "url": "/firefly/head/tutorials/chains/tezos_testnet.html#tezos-testnet", "relUrl": "/tutorials/chains/tezos_testnet.html#tezos-testnet" },"787": { @@ -4733,29 +4733,29 @@ "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://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 tezos dev 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 | See the list of Tezos public RPC nodes and select an HTTPS RPC node. | . To do this, run the following command: . ff init tezos dev 1 \\ --multiparty=false \\ --remote-node-url <selected RPC endpoint> . NOTE: The public RPC nodes may have limitations or may not support all FF required RPC endpoints. Therefore it’s not recommended to use ones for production and you may need to run own node or use third-party vendors. ", "url": "/firefly/head/tutorials/chains/tezos_testnet.html#creating-a-new-stack", "relUrl": "/tutorials/chains/tezos_testnet.html#creating-a-new-stack" - },"791": { + },"790": { "doc": "pages.tezos_testnet", "title": "Start the stack", "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": { + },"791": { "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. 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" + },"792": { + "doc": "pages.tezos_testnet", + "title": "Use the public testnet", + "content": "Now that you have everything set up, you can follow one of the other FireFly guides such as Custom Smart Contracts. For detailed instructions on deploying a custom smart contract to Tezos, please see the Tezos docs for instructions using various tools. ", + "url": "/firefly/head/tutorials/chains/tezos_testnet.html#use-the-public-testnet", + "relUrl": "/tutorials/chains/tezos_testnet.html#use-the-public-testnet" },"793": { "doc": "pages.tezos_testnet", "title": "pages.tezos_testnet", diff --git a/head/tutorials/chains/tezos_testnet.html b/head/tutorials/chains/tezos_testnet.html index b354680edd..439ea62e23 100644 --- a/head/tutorials/chains/tezos_testnet.html +++ b/head/tutorials/chains/tezos_testnet.html @@ -295,13 +295,13 @@
tezosconnect.yml
config fileThis guide will walk you through the steps to create a local FireFly development environment and connect it to the public Tezos Ghostnet testnet.
@@ -333,25 +333,6 @@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.
tezosconnect.yml
config file
-
-
- 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.
tezos
with 1
membermultiparty
mode. We are going to be using this FireFly node as a Web3 gateway, and we don’t need to communicate with a consortium heretezosconnect.yml
config fileTo do this, run the following command:
ff init tezos dev 1 \
--multiparty=false \
- --connector-config ~/Desktop/tezosonnect.yml
+ --remote-node-url <selected RPC endpoint>
+NOTE: The public RPC nodes may have limitations or may not support all FF required RPC endpoints. Therefore it’s not recommended to use ones for production and you may need to run own node or use third-party vendors.
+
On the Transfers tab from you account page you will see the actual transfer of the XTZ from the faucet.
Now that you have everything set up, you can follow one of the other FireFly guides such as Custom Smart Contracts. For detailed instructions on deploying a custom smart contract to Tezos, please see the Tezos docs for instructions using various tools.
diff --git a/head/tutorials/custom_contracts/images/simple_storage_swagger.png b/head/tutorials/custom_contracts/images/simple_storage_swagger.png index e5f7e9c451..1d49237f26 100644 Binary files a/head/tutorials/custom_contracts/images/simple_storage_swagger.png and b/head/tutorials/custom_contracts/images/simple_storage_swagger.png differ diff --git a/head/tutorials/custom_contracts/images/tezos_contract_deployment.png b/head/tutorials/custom_contracts/images/tezos_contract_deployment.png index d9d952de24..5f17421e4c 100644 Binary files a/head/tutorials/custom_contracts/images/tezos_contract_deployment.png and b/head/tutorials/custom_contracts/images/tezos_contract_deployment.png differ diff --git a/head/tutorials/custom_contracts/images/tezos_contract_deployment2.png b/head/tutorials/custom_contracts/images/tezos_contract_deployment2.png index a75e1725c4..8b84d17946 100644 Binary files a/head/tutorials/custom_contracts/images/tezos_contract_deployment2.png and b/head/tutorials/custom_contracts/images/tezos_contract_deployment2.png differ diff --git a/head/tutorials/custom_contracts/tezos.html b/head/tutorials/custom_contracts/tezos.html index 15c24bf7c3..1305caad83 100644 --- a/head/tutorials/custom_contracts/tezos.html +++ b/head/tutorials/custom_contracts/tezos.html @@ -324,7 +324,7 @@
Here we can see that our new contract address is KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s
. This is the address that we will reference in the rest of this guide.
Here we can see that our new contract address is KT1ED4gj2xZnp8318yxa5NpvyvW15pqe4yFg
. This is the address that we will reference in the rest of this guide.
{
- "id": "c655704a-f0e2-4aa3-adbb-c7bf3280cdc2",
- "namespace": "default",
- "name": "simplestorage",
- "description": "",
- "version": "v1.0.0",
- "methods": [
- {
- "id": "6f707105-d8b5-4808-a864-51475086608d",
- "interface": "c655704a-f0e2-4aa3-adbb-c7bf3280cdc2",
- "name": "replace",
- "namespace": "default",
- "pathname": "replace",
- "description": "",
- "params": [
+ "id": "f9e34787-e634-46cd-af47-b52c537404ff",
+ "namespace": "default",
+ "name": "simplestorage",
+ "description": "",
+ "version": "v1.0.0",
+ "methods": [
{
- "name": "newValue",
- "schema": {
- "type": "integer",
- "details": {
- "type": "integer",
- "internalType": "integer"
- }
- }
+ "id": "78f13a7f-7b85-47c3-bf51-346a9858c027",
+ "interface": "f9e34787-e634-46cd-af47-b52c537404ff",
+ "name": "set",
+ "namespace": "default",
+ "pathname": "set",
+ "description": "",
+ "params": [
+ {
+ "name": "newValue",
+ "schema": {
+ "type": "integer",
+ "details": {
+ "type": "integer",
+ "internalType": "integer"
+ }
+ }
+ }
+ ],
+ "returns": []
+ },
+ {
+ "id": "ee864e25-c3f7-42d3-aefd-a82f753e9002",
+ "interface": "f9e34787-e634-46cd-af47-b52c537404ff",
+ "name": "get",
+ "namespace": "tezos",
+ "pathname": "get",
+ "description": "",
+ "params": [],
+ "returns": []
}
- ],
- "returns": []
- }
- ]
+ ]
}
{
"name": "simple-storage",
"interface": {
- "id": "c655704a-f0e2-4aa3-adbb-c7bf3280cdc2"
+ "id": "f9e34787-e634-46cd-af47-b52c537404ff"
},
"location": {
- "address": "KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s"
+ "address": "KT1ED4gj2xZnp8318yxa5NpvyvW15pqe4yFg"
}
}
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.
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/set
endpoint to set the integer value on-chain. Let’s set it to the value of 3
right now.
POST
http://localhost:5000/api/v1/namespaces/default/apis/simple-storage/invoke/replace
POST
http://localhost:5000/api/v1/namespaces/default/apis/simple-storage/invoke/set
{
"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.
{
- "id": "cb38a538-7093-4150-8a80-6097a666df82",
- "namespace": "default",
- "tx": "5860befb-9f76-4aa0-a67c-55718b2c46d6",
+ "id": "87c7ee1b-33d1-46e2-b3f5-8566c14367cf",
"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.
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 smart contracts in FireFly. To see what the value is now, we can query the smart contract.
To see the result of the operation, call /operations
endpoint with the operation ID from the previous step.
To make a read-only request to the blockchain to check the current value of the stored integer, we can make a POST
to the query/get
endpoint.
GET
http://localhost:5000/api/v1/operations/cb38a538-7093-4150-8a80-6097a666df82?fetchstatus=true
POST
http://localhost:5000/api/v1/namespaces/default/apis/simple-storage/query/get
{}
+
{
- "id": "cb38a538-7093-4150-8a80-6097a666df82",
- "namespace": "default",
- "tx": "5860befb-9f76-4aa0-a67c-55718b2c46d6",
- "type": "blockchain_invoke",
- "status": "Succeeded",
- "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"
- },
- "output": {
- "contractLocation": {
- "address": "KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s"
- },
- "headers": {
- "requestId": "default:cb38a538-7093-4150-8a80-6097a666df82",
- "type": "TransactionSuccess"
- },
- "protocolId": "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",
- "transactionHash": "opMjGX58akxboipsxMcTv5yc5M4Y2ZCGktos4E26zgEpgtHop7g"
- },
- "detail": {
- "receipt": {
- "blockHash": "BLy9BdEjBvHvhYkt8tR4wTQzHagCUmweh8K8uM6X5gXzPLbCmzP",
- "blockNumber": "4012016",
- "contractLocation": {
- "address": "KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s"
- },
- "extraInfo": [
- {
- "consumedGas": "1279",
- "contractAddress": "KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s",
- "counter": "18602183",
- "errorMessage": null,
- "fee": "404",
- "from": "tz1cuFw1E2Mn2bVS8q8d7QoCb6FXC18JivSp",
- "gasLimit": "1380",
- "paidStorageSizeDiff": "0",
- "status": "applied",
- "storage": "3",
- "to": "KT1D254HTPKq5GZNVcF73XBinG9BLybHqu8s"
- }
- ],
- "protocolId": "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",
- "success": true,
- "transactionIndex": "0"
- },
- "status": "Succeeded"
- }
+ "3"
}
Here we can see detail.receipt.extraInfo.storage
section, which displays the latest state of the contract storage state after invoking the operation and that the value of the storage
variable was changed to 3
.
+NOTE: Some contracts may have queries that require input parameters. That’s why the query endpoint is a
+POST
, rather than aGET
so that parameters can be passed as JSON in the request body. This particular function does not have any parameters, so we just pass an empty JSON object.