ZkSync is a layer 2 scaling solution for Ethereum, which offers low gas costs and fast transactions without sacrificing security.!
Add ZkSync Era network:
- Let's go to ChainList and enable MetaMask :
- 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.
We are testing sites that are available on the ZkSync Era network:
- Let's go to the site mute.
- In chapter Swap exchange ETH per token 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.
- Go to the section DAO and freeze our coins Mute. After a successful lock, you can see the coins in the section redeem.
- 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.
- 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):
- 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.
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).
- Go to the section source control and press the button Clone Repository and paste this link: https://github.com/sevRipen/Greeter
- We open Terminal (picture below) and insert one of the commands, depending on your version:
yarn init -yor
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 compileor
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.
- 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-zksyncor
npx hardhat deploy-zksyncand 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.
- 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.
- On this site, select the section below Contract and press the button Verify Smart Contract
- 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
- Enter the Solidity Contract Code - is in the file Greeter.sol (copy everything!)
- Constructor Arguments - copy from the terminal after the successful creation of the contract.
We press the button 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!
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.
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.
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.