ZkSync Era - TestNet, Deploy contracta ! Step by step guide!

ZkSync Era - TestNet, Deploy contracta !

ZkSync is a layer 2 scaling solution for Ethereum, which offers low gas costs and fast transactions without sacrificing security.!

Add ZkSync Era network:
Переходим на ChainList и подключаем МетаМаск
  • Enter in the search ZkSync and check the box Include testnets.
  • Choose ZkSync Era Testnet and press Add to Metamask.
Getting test tokens:
  • First, we get test tokens in the network goerli and after that we translate through the official Bridge ZkSync Era.
получаем тестовые токены в сети Goerli

We are testing sites that are available on the ZkSync Era network:

Mute

  • Let's go to the site mute.
  • In chapter Swap exchange ETH per token Mute :
В разделе Swap обмениваем ЕТН на токен Mute
  • Go to the section pool and pick a couple WETH/Mute and add liquidity.
    Additions: leave a little Mute on balance. After successful addition, you can remove some of the tokens from the pool or add more ETH/Mute.
выбираем пару WETH/Mute и добавляем ликвидность
  • Go to the section DAO and freeze our coins Mute. After a successful lock, you can see the coins in the section redeem.
замораживаем свои монеты Mute
  • Depending on how many lock days you have chosen, after the expiration of the period it is better to go to the site and pick up the frozen coins and repeat all the steps.

space fi :

  • Let's go to the site space fi.
  • Choose a tab swap and make several exchanges + obligatory exchange for a token tSpace.
обязательный обмен на токен tSpace.
  • Go to tab Pool and add some pool, one of which will be with a coin tSpace (possible by pressing the button Supply nothing will happen to you, but after 2-3 repetitions everything will work out):
Переходим во вкладку Pool и добавляем несколько pool
  • After successfully adding liquidity, we take away part or all of the tokens.
забираем часть или полностью все токены

This is where testing of the sites ended, after a while you can carry out all the actions again - this will only be + for you.

Deploy smart contracts:

Now we will create our smart contract. Thanks to our friend and friend CryptoRelax we have simplified all actions.

  • First of all, download the program Visual Studio Code if you don't have it. We checked on MAC, but on Windows also everything works great.
  • We launch Visual Studio Code.
  • In the tab "Extensions" download extensions via search Solidity, NpM Intellisense.
скачиваем расширения Solidity, NpM Intellisense

Additions : if in the course of work in VSC gives errors and a window pops up in the lower right corner with a suggestion to download packages - we agree (it can be different for everyone).

Переходим в раздел Source Control и нажимаем кнопку Clone Repository
  • We open Terminal (picture below) and insert one of the commands, depending on your version:yarn init -y or npm init -y
Открываем Терминал и вставляем одну из команд
  • Then we enter: sudo npm i -D typescript ts-node ethers@^5.7.2 zksync-web3@^0.13.1 hardhat @matterlabs/hardhat-zksync-solc @matterlabs/hardhat-zksync-deploy
  • After the installation is complete, one of these commands, depending on which one you entered for the first time: yarn hardhat compile or npx hardhat compile
  • On the left side we find the section deploy and open it. Finding a file deploy.ts and we press it. After we need to insert our key MetaMask. The figure below shows where you can do this.
Находим файл deploy.ts и нажимаем его
  • It is also desirable to set auto-save, go to the section Settings 6 write in search Auto Save and choose afterDelay.
  • And the last command: yarn hardhat deploy-zksync or npx hardhat deploy-zksync and wait for the end of the deployment of the contract.

You must have in your wallet ETH to pay a commission. On average, the last item is completed in 3-5 minutes, so after entering the command, you need to wait a bit. But that's not all, after the received data, you need to activate the contract and check its operation.

Contract Verification:
  • follow the link https://goerli.explorer.zksync.io/
  • After successfully creating a contract, copy in our terminal Visual Studio Code our Greeter was deployed to 0x… and insert into the search on the site, which is written above.
копируем в нашем терминале Visual Studio Code
вставляем в поиск на сайте
  • On this site, select the section below Contract and press the button Verify Smart Contract
выбираем ниже раздел Сontract
  • Our next step will be to fill in our smart contract, below we will provide the final filling and describe a little where to get the data + at AMA we will tell and show everything ( video recording will remain )
заполнения нашего смарт контракта
  • contract name : everyone has the same Greeter
  • Zksolc Version and Solc Version is in the file hardhat.config.ts
hardhat.config.ts
  • Enter the Solidity Contract Code - is in the file Greeter.sol (copy everything!)
в файле Greeter.sol ( копируем всё ! )
  • Constructor Arguments - copy from the terminal after the successful creation of the contract.
Constructor Arguments

We press the button Verify Smart Contract.

 Verify Smart Contract

After successful verification, we need to check the operation of our smart contract, so we return to our smart contracts via button Back to contract and go to section contract.

Choose a section read and press the button Query, the following message should appear: Hi there!

Hi there !

Now go to the tab Write, open it, write any phrase, for example Hi ZkSync or as we have in the example and through the button Write we confirm the transaction.

через кнопку Write подтверждаем транзакцию

After the transaction is completed, we return to the section read and press the button Query and we should see the phrase that we wrote in the last action, if so, congratulations, your smart contract is open and working successfully.

нажимаем кнопку Query

This is only the first smart contract, if you like it and want to open another contract with us on a separate server, then we will wait for you feedback.

VC | Telegram | Twitter | Youtube | Website

More news: