More

    Tezos – Deploying and Exploring a Smart Contract


    As in the articles prior to this, we learned the basics of Tezos blockchain and about writing a smart contract. Moving further, in this article you’ll be deploying and exploring smart contracts on the Tezos blockchain. Furthermore, in the last two articles, you learned about:

    • Introduction to Tezos
    • Tezos Development tools
    • Writing Smart Contracts using SmartPy

    Further in this article, you will learn to set up a wallet, deploy and explore smart contracts.

    This is the 3rd part of our series on Tezos. Read our earlier articles which are Introduction to Tezos and Smart Contract SmartPy for more information on the subject.

    What is a Temple wallet?

    Before deploying your smart contract, you will need a wallet to handle transactions on the Tezos blockchain. Here you will learn to set up Temple Wallet.

    Temple Wallet is an open-source and easy-to-use browser extension wallet for interacting with the Tezos Ecosystem. You can use it to handle transactions for your Tezos DApp’s. It supports all FA1.2 and FA2 tokens. You can also create multiple accounts on Temple wallet and it also has a feature for token delegation to bakers.

    Temple Wallet
    Temple wallet

    How to Install Temple wallet?

    • Install temple wallet by clicking here.
    • Select your browser and add the temple wallet extension
    • Once installed, create an account by clicking on the top right corner.
    • New accounts will have 0 balance. Ping @tezos_faucet_bot on Telegram to get free tez on the testnets.
    Installing Temple WalletInstalling Temple Wallet
    Installing temple wallet

    To know more about temple wallet, go to Temple wallet.

    Originating smart contract

    Follow the steps below to deploy a smart contract:

    • Before deploying your contract, run your contract to test your test cases. If everything works fine, then click on Deploy Michelson Contract on the right.
    Running Contract TestRunning Contract Test
    Running Contract test
    • You will be directed to the origination page. Select the network and nodes and then connect with the temple wallet.
    • Click on Estimate cost from RPC to estimate storage and gas limit.
    Estimate Cost From RpcEstimate Cost From Rpc
    Estimate cost from RPC
    • Accept the Pre Signature Information and sign the payload.
    • Once everything looks good, you can deploy your contract.
    • If everything works fine, you will see this. Click on Open Explorer to explore the smart contract.
    Opening ExplorerOpening Explorer
    Opening explorer

    Blockchain Explorers

    Blockchain explorers or block explorers are like a search engine on the blockchain which is used to track any activity on the blockchain. Its use cases are different for various users out of which some are mentioned below:

    • DApp developers can use it as a debugging tool to observe the state of their contract running on testnets.
    • Users of smart contracts can view Michelson code, storage, and history.
    • Normal users check if their coins are safe.
    • Blockchain engineers use it to debug new features on a test network.

    Block explorer consists of:

    1. An indexer – It is a node operator that extracts on-chain data and stores it into the database.
    2. An API – It queries the database.
    3. A Frontend – It displays the data

    Available Tezos Explorers

    In this lesson you will be interacting with your smart contract using:

    • Better Call Dev (BCD) – BCD is a Tezos explorer where you can explore DApps, search for your smart contract using your contract’s address and it gives you complete details about your contract.
    Better Call DevBetter Call Dev
    Better Call Dev
    • SmartPy Explorer – On SmartPy Explorer, you can enter your contract’s address and then interact with your contract using operation builder. You can find more explorers here.

    Interacting with Smart contracts

    Now, you will interact with your smart contract using BCD and SmartPy Explorer that you had deployed.

    SmartPy Explorer

    Go to SmartPy Explorer and enter the contract address starting with KT generated when you deployed your contract. It will search for your contract and display its details like Node, Contract Data, and Storage.

    Interacting With Smart ContractsInteracting With Smart Contracts
    Interacting with Smart Contracts
    • You can interact with the contract using Operation Builder.
    • Select the entry point you want to call, enter the parameters, and hit the Build Transaction button.
    New Operation BuilderNew Operation Builder
    New Operation Builder
    • Connect with the Temple wallet before sending the transaction.
    • Click on Send Transaction button.
    • Once the transaction is completed, refresh the page to see the storage.

    Better Call Dev

    Go to BCD and search for your contract using its contracts address. Once you have opened the contract, you can do the following here:

    • View the Operations history
    Tezos - Deploying And Exploring A Smart ContractTezos - Deploying And Exploring A Smart Contract
    View Operation History
    • Contract’s Michelson code viewing
    View Contract'S Michelson CodeView Contract'S Michelson Code
    View contract’s Michelson code

    For interacting with the contract, go to the Interact tab, select the entry point that you want to call from the right and fill in the details and execute. Before executing the final transaction, click on simulate to test if everything works fine or not. Once it all looks good, select Temple wallet to execute the final transaction.

    Interacting With ContractInteracting With Contract
    Interacting with contract

    To view your contract’s updated storage, go to Storage Tab on top. Here you can view your contract state.

    Viewing Contract StorageViewing Contract Storage
    Viewing Contract Storage

    This was the third article in the series of four articles listed below:

    1. Introduction to Tezos blockchain and Tezos developer tools
    2. Writing smart contract using SmartPy
    3. Deploying and exploring smart contract
    4. Integrating with frontend

    Since, now you have got a basic understanding of what is tezos, writing smart contracts using SmartPy, deploying and exploring smart contracts, in the next part you will be learning to integrate your smart contract with the frontend.



    Source link

    Stay in the Loop

    Get the daily email from CryptoNews that makes reading the news actually enjoyable. Join our mailing list to stay in the loop to stay informed, for free.

    Latest stories

    - Advertisement -

    You might also like...