 {"id":899,"date":"2023-01-04T04:21:24","date_gmt":"2023-01-03T18:21:24","guid":{"rendered":"https:\/\/test.secrypt.tech\/?page_id=899"},"modified":"2023-01-05T17:53:24","modified_gmt":"2023-01-05T07:53:24","slug":"using-chainstack","status":"publish","type":"page","link":"https:\/\/test.secrypt.tech\/index.php\/using-chainstack\/","title":{"rendered":"Using Chainstack"},"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 Chainstack and Foundry<\/h2>\n<h4><strong>Overview<\/strong><u><\/u><\/h4>\n<p>This section guides you through deploying a Hello World contract using\u00a0<u>Chainstack<\/u>\u00a0and\u00a0<u>Foundry<\/u>\u00a0on the SECRYPT testnet.<\/p>\n<p>Chainstack provides infrastructure for Ethereum-based applications and other blockchains. They maintain nodes and guarantee their connection to the network and also offer an interface to interact with mainnet and testnets.<\/p>\n<p>Foundry is a fast toolkit for Ethereum application development written in Rust. It provides testing, interaction with EVM smart contracts, sending transactions, and blockchain data retrieval.<\/p>\n<p>TIP<\/p>\n<p>If you have any questions, reach out in the\u00a0<u>Chainstack Discord<\/u>\u00a0server.<\/p>\n<h4><strong>What you will learn<\/strong><u><\/u><\/h4>\n<p>Create a Hello World contract, using Chainstack to deploy a SECRYPT node and Foundry to deploy the contract.<\/p>\n<h4><strong>What you will do<\/strong><u><\/u><\/h4>\n<ol>\n<li>Deploy a SECRYPT node using Chainstack<\/li>\n<li>Set up Foundry<\/li>\n<li>Create the smart contract<\/li>\n<li>Deploy the smart contract.<\/li>\n<\/ol>\n<h4><strong>Deploy a SECRYPT Testnet Node<\/strong><u><\/u><\/h4>\n<p>You need a node to deploy a smart contract to the blockchain network. Follow the steps below to get your node up and running:<\/p>\n<p>Step 1\u00a0\u2192\u00a0Sign up with\u00a0<u>Chainstack<\/u><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/Asasd.jpg\" alt=\"\" width=\"1380\" height=\"594\" \/><\/p>\n<p>Step 2\u00a0\u2192\u00a0Follow the instructions on how to\u00a0<u>deploy a Testnet node<\/u><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/test.secrypt.tech\/wp-content\/uploads\/2023\/01\/2222-1024x841.jpg\" alt=\"\" width=\"1024\" height=\"841\" \/><\/p>\n<p>Step 3\u00a0\u2192\u00a0Get the\u00a0<u>deployed node\u2019s HTTPS endpoint<\/u><\/p>\n<h4><strong>Install Foundry<\/strong><u><\/u><\/h4>\n<p>Foundry is a development toolkit to work with smart contracts. To begin working with it, you need to install the Rust coding language first.<\/p>\n<ol>\n<li><u>Install Rust<\/u>.<\/li>\n<li><u>Install Foundry<\/u>.<\/li>\n<\/ol>\n<h4><strong>Initialize with Foundry<\/strong><u><\/u><\/h4>\n<p>To create a boilerplate project, navigate to your working directory and run:<\/p>\n<p style=\"text-align: center;\">forge init PROJECT_NAME<br \/><em>\/\/ PROJECT_NAME &#8211; name of project<\/em><\/p>\n<h4><strong>Fund Your Account<\/strong><u><\/u><\/h4>\n<p>You will need a wallet account to deploy the smart contract. You can use\u00a0<u>Metamask<\/u>\u00a0for that. You also need to pay gas on the network to deploy the contract. Just copy your wallet address and get SECRYPT SXC token\u00a0<u>through the faucet<\/u>.<\/p>\n<h4><strong>Create the Hello World contract<\/strong><u><\/u><\/h4>\n<p>In the initialized Foundry project in\u00a0src\/, create\u00a0HelloWorld.sol:<\/p>\n<p><em>\/\/ SPDX-License-Identifier: None<\/em><\/p>\n<p><em>\/\/ Specifies the version of Solidity, using semantic versioning.<\/em><br \/><em>\/\/ Learn more: https:\/\/solidity.readthedocs.io\/en\/v0.5.10\/layout-of-source-files.html#pragma<\/em><br \/>pragma solidity &gt;=0.8.9;<\/p>\n<p><em>\/\/ Defines a contract named `HelloWorld`.<\/em><br \/><em>\/\/ A contract is a collection of functions and data (its state). Once deployed, a contract resides at a specific address on the Ethereum blockchain. Learn more: https:\/\/solidity.readthedocs.io\/en\/v0.5.10\/structure-of-a-contract.html<\/em><br \/>contract HelloWorld {<\/p>\n<p>\u00a0\u00a0 <em>\/\/Emitted when update function is called<\/em><br \/>\u00a0\u00a0 <em>\/\/Smart contract events are a way for your contract to communicate that something happened on the blockchain to your app front-end, which can be &#8216;listening&#8217; for certain events and take action when they happen.<\/em><br \/>\u00a0\u00a0 event UpdatedMessages(string oldStr, string newStr);<\/p>\n<p>\u00a0\u00a0 <em>\/\/ Declares a state variable `message` of type `string`.<\/em><br \/>\u00a0\u00a0 <em>\/\/ State variables are variables whose values are permanently stored in contract storage. The keyword `public` makes variables accessible from outside a contract and creates a function that other contracts or clients can call to access the value.<\/em><br \/>\u00a0\u00a0 string public message;<\/p>\n<p>\u00a0\u00a0 <em>\/\/ Similar to many class-based object-oriented languages, a constructor is a special function that is only executed upon contract creation.<\/em><br \/>\u00a0\u00a0 <em>\/\/ Constructors are used to initialize the contract&#8217;s data. Learn more:https:\/\/solidity.readthedocs.io\/en\/v0.5.10\/contracts.html#constructors<\/em><br \/>\u00a0\u00a0 constructor(string memory initMessage) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 <em>\/\/ Accepts a string argument `initMessage` and sets the value into the contract&#8217;s `message` storage variable).<\/em><br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 message = initMessage;<br \/>\u00a0\u00a0 }<\/p>\n<p>\u00a0\u00a0 <em>\/\/ A public function that accepts a string argument and updates the `message` storage variable.<\/em><br \/>\u00a0\u00a0 function update(string memory newMessage) public {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 string memory oldMsg = message;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 message = newMessage;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 emit UpdatedMessages(oldMsg, newMessage);<br \/>\u00a0\u00a0 }<br \/>}<\/p>\n<h4><strong>Deploy the Contract<\/strong><strong><u><\/u><\/strong><\/h4>\n<p>At this point, you are ready to deploy your contract:<\/p>\n<ul>\n<li>You have your own node on the SECRYPT Testnet network through which you will deploy the contract.<\/li>\n<li>You have Foundry that you will use to deploy the contract.<\/li>\n<li>You have a funded account that will deploy the contract.<\/li>\n<\/ul>\n<p>To deploy the contract, run:<\/p>\n<p>forge create HelloWorld &#8211;constructor-args &#8220;Hello&#8221; &#8211;contracts CONTRACT_PATH &#8211;private-key PRIVATE_KEY &#8211;rpc-url HTTPS_ENDPOINT<\/p>\n<p>Here,<\/p>\n<ul>\n<li>CONTRACT_PATH \u2014 path to your&nbsp;HelloWorld.sol&nbsp;file.<\/li>\n<li>PRIVATE_KEY \u2014 the private key from your account.<\/li>\n<li>HTTPS_ENDPOINT \u2014&nbsp;<u>your node&#8217;s endpoint<\/u>.<\/li>\n<\/ul>\n<p>Example:<\/p>\n<p>forge create HelloWorld &#8211;constructor-args &#8220;Hello&#8221; &#8211;contracts \/root\/foundry\/src\/HelloWorld.sol &#8211;private-key d8936f6eae35c73a14ea7c1aabb8d068e16889a7f516c8abc482ba4e1489f4cd &#8211;rpc-url https:\/\/nd-123-456-789.p2pify.com\/3c6e0b8a9c15224a8228b9a98ca1531d<\/p>\n<p><b>TIP<\/b><\/p>\n<p>You can always check the contract&#8217;s deployment on&nbsp;<a href=\"https:\/\/explorer-testnet.secrypt.tech\/\">https:\/\/explorer-testnet.secrypt.tech\/<\/a> using the newly-generated hash from the last step.<\/p>\n<h4><strong>Test the Contract<\/strong><strong><u><\/u><\/strong><\/h4>\n<p>There is a&nbsp;forge test&nbsp;command in case you need to check whether the contract is working fine. Foundry provides many&nbsp;<u>options<\/u>&nbsp;(flags) for more specific tests. Learn more about writing tests, advanced testing and other features at&nbsp;<u>Foundry&#8217;s documentation<\/u>.<\/p>\n<p>Congratulations! You have deployed your Hello World smart contract on SECRYPT.<\/p>\n<p>See also Chainstack docs for more SECRYPT -related&nbsp;<u>tutorials<\/u>&nbsp;and&nbsp;<u>tools<\/u>.<\/p>\n<p><u>Edit this page<\/u><\/p>\n<p><strong>&nbsp;<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Deploy a Smart Contract Using Chainstack and Foundry Overview This section guides you through deploying a Hello World contract using\u00a0Chainstack\u00a0and\u00a0Foundry\u00a0on the SECRYPT testnet. Chainstack provides infrastructure for Ethereum-based applications and other blockchains. They maintain nodes and guarantee their connection to the network and also offer an interface to interact with mainnet and testnets. Foundry is [&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-899","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/pages\/899","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=899"}],"version-history":[{"count":17,"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/pages\/899\/revisions"}],"predecessor-version":[{"id":1405,"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/pages\/899\/revisions\/1405"}],"wp:attachment":[{"href":"https:\/\/test.secrypt.tech\/index.php\/wp-json\/wp\/v2\/media?parent=899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}