 {"id":881,"date":"2023-01-04T03:58:32","date_gmt":"2023-01-03T17:58:32","guid":{"rendered":"https:\/\/test.secrypt.tech\/?page_id=881"},"modified":"2023-01-05T17:53:01","modified_gmt":"2023-01-05T07:53:01","slug":"using-quicknode","status":"publish","type":"page","link":"https:\/\/test.secrypt.tech\/index.php\/using-quicknode\/","title":{"rendered":"Using QuickNode"},"content":{"rendered":"<style>\/*! elementor - v3.9.2 - 21-12-2022 *\/\n.elementor-widget-image{text-align:center}.elementor-widget-image a{display:inline-block}.elementor-widget-image a img[src$=\".svg\"]{width:48px}.elementor-widget-image img{vertical-align:middle;display:inline-block}<\/style>\n<p>\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/test.secrypt.tech\/\"><br \/>\n\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/elementor\/thumbs\/image-removebg-preview-pusb43b4fkgjv12hawycptkh3fmhfjngdaesxsjilk.png\" title=\"image-removebg-preview\" alt=\"image-removebg-preview\" \/>\t\t\t\t\t\t\t\t<\/a><\/p>\n<style>\/*! elementor - v3.9.2 - 21-12-2022 *\/\n.elementor-column .elementor-spacer-inner{height:var(--spacer-size)}.e-con{--container-widget-width:100%}.e-con-inner>.elementor-widget-spacer,.e-con>.elementor-widget-spacer{width:var(--container-widget-width,var(--spacer-size));--align-self:var(--container-widget-align-self,initial);--flex-shrink:0}.e-con-inner>.elementor-widget-spacer>.elementor-widget-container,.e-con-inner>.elementor-widget-spacer>.elementor-widget-container>.elementor-spacer,.e-con>.elementor-widget-spacer>.elementor-widget-container,.e-con>.elementor-widget-spacer>.elementor-widget-container>.elementor-spacer{height:100%}.e-con-inner>.elementor-widget-spacer>.elementor-widget-container>.elementor-spacer>.elementor-spacer-inner,.e-con>.elementor-widget-spacer>.elementor-widget-container>.elementor-spacer>.elementor-spacer-inner{height:var(--container-widget-height,var(--spacer-size))}<\/style>\n<style>\/*! elementor - v3.9.2 - 21-12-2022 *\/\n.elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading .elementor-heading-title.elementor-size-small{font-size:15px}.elementor-widget-heading .elementor-heading-title.elementor-size-medium{font-size:19px}.elementor-widget-heading .elementor-heading-title.elementor-size-large{font-size:29px}.elementor-widget-heading .elementor-heading-title.elementor-size-xl{font-size:39px}.elementor-widget-heading .elementor-heading-title.elementor-size-xxl{font-size:59px}<\/style>\n<h2>Deploy a Smart Contract Using QuickNode<\/h2>\n<h4><b>Overview<\/b><\/h4>\n<p>Python is one of the most versatile programming languages; from researchers running their test models to developers using it in heavy production environments, it has use cases in every possible technical field.<\/p>\n<p>In this tutorial, you will learn how to use&nbsp;Brownie&nbsp;framework to write and deploy a smart contract by leveraging&nbsp;QuickNode&nbsp;testnet nodes for SECRYPT.<\/p>\n<p><b>TIP<\/b><\/p>\n<p>To contact the Quicknode team, send them a message or tag them on Twitter&nbsp;<u>@QuickNode<\/u>.<\/p>\n<h4><strong>Prerequisites<\/strong><\/h4>\n<ul>\n<li>Python3 installed<\/li>\n<li>A SECRYPT node<\/li>\n<li>Code editor<\/li>\n<li>Command line interface<\/li>\n<\/ul>\n<h4><strong>What you will do<\/strong><\/h4>\n<ol>\n<li>Set up Brownie<\/li>\n<li>Get access to Quicknode test nodes<\/li>\n<li>Compile and Deploy a smart contract<\/li>\n<li>Check the deployed contract data<\/li>\n<\/ol>\n<h4><strong>What is Brownie?<\/strong><\/h4>\n<p>Smart contract development is majorly dominated by JavaScript-based libraries like&nbsp;web3.js,&nbsp;ethers.js,&nbsp;Truffle, and&nbsp;Hardhat. Python is a versatile, highly used language and can also be used for smart contracts \/ Web3 development;&nbsp;web3.py&nbsp;is a compelling Python library that fulfills Web3 needs. Brownie framework is built on top of&nbsp;web3.py.<\/p>\n<p>Brownie&nbsp;is a Python-based framework to develop and test smart contracts. Brownie has support for both Solidity and Vyper contracts, and it even provides contract testing via&nbsp;pytest.<\/p>\n<p>To demonstrate the process of writing and deploying a smart contract with Brownie, we will use&nbsp;Brownie-mixes&nbsp;which are template projects. Specifically, we will use a&nbsp;token mix, which is a template of the ERC-20 implementation.<\/p>\n<h4><strong>Install dependencies<\/strong><\/h4>\n<p>Brownie is built on top of python3, so we need it installed to work with Brownie. Let us check if we have python3 installed on our system. To do so, type the following in your command line tool:<\/p>\n<p><b>python3 -V<\/b><\/p>\n<p>This should return the version of python3 installed. If not installed, download and install it from the official&nbsp;Python website.<\/p>\n<p>Let us make a project directory before installing Brownie, and make that project directory our current working directory:<\/p>\n<p>mkdir brownieDemo<br \/>cd brownieDemo<\/p>\n<p>Now that you have installed python3 on your system, let us install Brownie using pip, Python&#8217;s package manager. Pip is similar to what npm is for JavaScript. Type the following in your command line:<\/p>\n<p>pip3 install eth-brownie<\/p>\n<h4><b>TIP<\/b><\/h4>\n<p>If the install fails, you can use the following command instead:&nbsp;sudo pip3 install eth-brownie<\/p>\n<p>To check if Brownie was installed correctly, type&nbsp;brownie&nbsp;in your command line, and it should give the following output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/1-1024x516.jpg\" alt=\"\" width=\"1024\" height=\"516\"><\/p>\n<p>To get the token mix, simply type the following in your command line:<\/p>\n<p>brownie bake token<\/p>\n<p>This will create a new directory&nbsp;token\/&nbsp;in our&nbsp;brownieDemo&nbsp;directory.<\/p>\n<h4><strong>File structure<\/strong><strong><\/strong><\/h4>\n<p>First of all, navigate to the&nbsp;token&nbsp;directory:<\/p>\n<p>cd token<\/p>\n<p>Now, open the&nbsp;token&nbsp;directory in your text editor. Under the&nbsp;contracts\/&nbsp;folder you will find&nbsp;Token.sol, which is our main contract. You can write your own contracts or modify&nbsp;Token.sol&nbsp;file.<\/p>\n<p>Under the&nbsp;scripts\/&nbsp;folder, you will find&nbsp;token.py&nbsp;Python script. This script will be used to deploy the contract, and modifications are needed based on contracts.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/2-1024x415.jpg\" alt=\"\" width=\"1024\" height=\"415\"><\/p>\n<p>The contract is an ERC-20 contract. You can learn more about the ERC-20 standards and contracts in this&nbsp;guide on ERC-20 tokens.<\/p>\n<h4><strong>Booting your SECRYPT node<\/strong><strong><\/strong><\/h4>\n<p>QuickNode has a global network of SECRYPT Mainnet and SECRYPT Testnet nodes. They also run a&nbsp;free public SECRYPT RPC&nbsp;but if you get rate limited, you can sign up for a&nbsp;free trial node from QuickNode.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/3-1024x425.jpg\" alt=\"\" width=\"1024\" height=\"425\"><\/p>\n<p>Copy the&nbsp;HTTP URL, which will be useful later in the tutorial.<\/p>\n<h4><strong>Network and Account setup<\/strong><strong><\/strong><\/h4>\n<p>We need to set up our QuickNode endpoint with Brownie. To do so, type the following in your command line:<\/p>\n<p>brownie networks add Ethereum sxc_testnet host=YOUR_QUICKNODE_URL chainid=1144<\/p>\n<p>Replace&nbsp;YOUR_QUICKNODE_URL&nbsp;with the&nbsp;SECRYPT Testnet HTTP URL&nbsp;that we just received while booting our SECRYPT node.<\/p>\n<p>In the above command,&nbsp;Ethereum&nbsp;is the name of the environment, and&nbsp;SXC_testnet&nbsp;is the custom name of the network; you can give any name to your custom network.<\/p>\n<p>The next thing we need to do here is to create a new wallet using Brownie, to do so type the following in your command line:<\/p>\n<p>brownie accounts generate testac<\/p>\n<p>You will be asked to set up a password for your account! After completing the steps, this will generate an account along with a mnemonic phrase, save it offline. The name&nbsp;testac&nbsp;is the name for our account (You can choose any name that you like).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/4.jpg\" alt=\"\" width=\"1380\" height=\"684\"><\/p>\n<p><b>NOTE<\/b><\/p>\n<p>Mnemonic phrases can be used to recover an account or import the account to other&nbsp;<u>non-custodial wallets<\/u>. The account you see in the image above was just created for this guide.<\/p>\n<p>Copy the account address so that we can get some test SXC, which will be required to deploy our contract.<\/p>\n<h4><strong>Getting Testnet SXC<\/strong><strong><\/strong><\/h4>\n<p>We will need some test SXC tokens to pay for gas fees to deploy our smart contract.<\/p>\n<p>Copy the address of your account which we generated in this tutorial, paste it into the address field of&nbsp; SECRYPT faucet, and click on&nbsp;Submit. The faucet will send you 1 test SXC.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/5-1024x642.jpg\" alt=\"\" width=\"1024\" height=\"642\"><\/p>\n<h4><strong>Deploying your Smart Contract<\/strong><strong><\/strong><\/h4>\n<p>Before deploying the contract, you need to compile it using:<\/p>\n<p>brownie compile<br \/><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/6-1024x220.jpg\" alt=\"\" width=\"1024\" height=\"220\"><\/p>\n<p>Now open the&nbsp;scripts\/token.py&nbsp;in your text editor, and make the following changes:<\/p>\n<p style=\"text-align: center;\"><em>#!\/usr\/bin\/python3<\/em><br \/>from brownie import Token, accounts<\/p>\n<p>def main():<br \/>\u00a0\u00a0\u00a0 acct = accounts.load(&#8216;testac&#8217;)<br \/>\u00a0\u00a0\u00a0 return Token.deploy(&#8220;Test Token&#8221;, &#8220;TST&#8221;, 18, 1e21, {&#8216;from&#8217;: acct})<\/p>\n<p><b>EXPLANATION<\/b><\/p>\n<p>Using the above code, we have imported&nbsp;testac&nbsp;account which we created earlier, and stored it in&nbsp;acct&nbsp;variable. Also, in the next line, we have edited&nbsp;&#8216;from&#8217;:&nbsp;part to receive data from&nbsp;acct&nbsp;variable.<\/p>\n<p>Finally, we will deploy our smart contract:<\/p>\n<p>brownie run token.py &#8211;network sxc_testnet<\/p>\n<p>sxc_testnet&nbsp;is the name of the custom network which we created earlier. The prompt will ask you for the&nbsp;password&nbsp;that we set earlier while making the account.<\/p>\n<p>After running the above command, you must get the transaction hash, and Brownie will wait for the transaction to get confirmed. Once the transaction is confirmed, it will return the address at which our contract is deployed on the SECRYPT testnet.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/7.jpg\" alt=\"\" width=\"662\" height=\"164\"><\/p>\n<p>You can check out the deployed contract by copy-pasting the contract address at&nbsp; https:\/\/explorer-tetnet.secrypt.tech<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/8-1024x570.jpg\" alt=\"\" width=\"1024\" height=\"570\"><\/p>\n<h4><b>Testing the Contract<\/b><\/h4>\n<p>Brownie also offers the option of testing smart contracts functionalities. It uses the&nbsp;pytest&nbsp;framework to easily generate unit tests. You can find more information about writing tests on Bronwnie&nbsp;on their documentation.<\/p>\n<p>This is how contracts are deployed on SECRYPT using Brownie and QuickNode.<\/p>\n<p>QuickNode, just like SECRYPT, has always had an education-first approach providing developer&nbsp;guides,&nbsp;docs,&nbsp;tutorial videos&nbsp;and a&nbsp;community of Web3 developers&nbsp;who are eager to help each other.<\/p>\n<p>Edit this page<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Deploy a Smart Contract Using QuickNode Overview Python is one of the most versatile programming languages; from researchers running their test models to developers using it in heavy production environments, it has use cases in every possible technical field. In this tutorial, you will learn how to use&nbsp;Brownie&nbsp;framework to write and deploy a smart contract [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"elementor_header_footer","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-881","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/pages\/881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/comments?post=881"}],"version-history":[{"count":16,"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/pages\/881\/revisions"}],"predecessor-version":[{"id":1402,"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/pages\/881\/revisions\/1402"}],"wp:attachment":[{"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/media?parent=881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}