Let’s get started!
Deploy price: ~5$ in ETH
Deploy difficulty: Classic method (code) - difficult. Thirdweb method - easy.
Download Visual Studio Code from the official website: https://code.visualstudio.com/
Choose English language and leave the checkboxes in their default state.
After the installation, create a folder on your desktop named zksync
Download & install Node.js from its official website. During the installation, leave the settings unchanged. Afterwards, restart your PC.
Go back to VSCode, press CTRL + J to open the terminal.
Insert the following command into the terminal:
npm init -y
npm add -D typescript ts-node @types/node ethers@^5.7.2 zksync-web3@^0.14.3 @ethersproject/hash @ethersproject/web hardhat @matterlabs/hardhat-zksync-solc @matterlabs/hardhat-zksync-deploy
npm install @openzeppelin/contracts
hardhat.config.ts
hardhat.config.ts
and press CTRL + S to save the file:import "@matterlabs/hardhat-zksync-deploy";
import "@matterlabs/hardhat-zksync-solc";
module.exports = {
zksolc: {
version: "1.3.5",
compilerSource: "binary",
settings: {},
},
defaultNetwork: "zkSyncMainnet",
networks: {
zkSyncMainnet: {
url: "https://zksync2-mainnet.zksync.io",
ethNetwork: "mainnet",
zksync: true,
},
},
solidity: {
version: "0.8.17",
},
};
contracts
folder. Press on this folder and create the contract.sol
file in it. Any parameters (those in “ “ quotes) you can customize according to your needs (full token name & ticker). Insert the following code:// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Roccrypto is ERC20, Ownable {
constructor() ERC20("roccrypto", "rocc") {
_mint(msg.sender, 100 * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}
Press CTRL + S to save your file
Here we create a simple ERC-20 Token with the ticker rocc
. Any other contracts can be used from OpenZeppelin documentation. However, in order to deploy them, we have to understand JavaScript/TypeScript programming languages. If you want to deploy some other contracts which are not mentioned in this guide, and you don’t know any of this programming languages - use ChatGPT. It will easily write the deploy.ts
script for the contract you want to deploy.
Compile the contract by inserting the following command:
npx hardhat compile
zksync
folder and create a new folder named deploy
. In that file we must create the typescript file deploy.ts
. Insert the following code and change the 0x123…
addreess, to which the tokens will be minted. Press CTRL + S:import fs from "fs";
import { utils, Wallet } from "zksync-web3";
import * as ethers from "ethers";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
const PRIV_KEY = fs.readFileSync(".secret").toString();
export default async function (hre: HardhatRuntimeEnvironment) {
console.log(`Running deploy script for the Roccrypto contract`);
const wallet = new Wallet(PRIV_KEY);
const deployer = new Deployer(hre, wallet);
const artifact = await deployer.loadArtifact("Roccrypto");
const roccryptoContract = await deployer.deploy(artifact, []);
console.log("constructor args:" + roccryptoContract.interface.encodeDeploy([]));
const contractAddress = roccryptoContract.address;
console.log(`${artifact.contractName} was deployed to ${contractAddress}`);
// Mint some tokens to an address.
const to = "0x123..."; // Адрес куда минтить токены.
const amount = ethers.utils.parseEther("10"); // Сколько токенов нужно заминтить на этот адрес
const mintHandle = await roccryptoContract.mint(to, amount);
await mintHandle.wait();
console.log(`Minted ${amount} tokens to ${to}`);
}
Create a file named .secret
in general zksync
folder. We have to insert a private key from which the contract will be deployed. Keep in mind, that your address has to have a balance of ~5$ in ETH in zkSync Era mainnet. It is highly not recommended to hold a signifficant balance if you are unsure about your next actions. Please test first and then deploy on multiple accounts. I am not responsible for your funds.
Finally, deploy the contract with the command:
npx hardhat deploy-zksync
We’ve successfully deployed our contract and minted some rocc tokens to our address.
You can also deploy zkSync smart contracts by using Thirdweb. If you simply don’t like the classic method - you better use this one.
Token
Deploy now
Fill in the details of our token and make sure to select zkSync Era Mainnet
.
Press Deploy Now
and sign the transaction.
Deploy price: FREE (Goerli ETH)
Bridge: bridge.base.org/deposit
Deploy difficulty: Easy
To begin with, use the bridge to obtain ETH to your wallet.
Base Goerli Testnet
, and connect your wallet to it. Make sure you switched the network afterwards.Choose ERC-20
token and fill in the parameters according to your preferences. Check the boxes for Mintable
and Burnable
Press Open in Remix
Check the box for Auto compile
Injected Provider - Metamask
and connect the wallet to the website.Deploy
button and confirm the transaction in MetamaskNow we have successfully deployed the contract on Base! However, to avoid repeating the same contracts every time, I suggest experimenting and deploying different ones.
Deploy price: FREE (Goerli ETH)
Bridge: scroll.io/bridge
Deploy difficulty: Easy
To begin with, use the bridge to obtain ETH to your wallet.
Scroll Alpha Testnet
and connect your wallet to it. Make sure you switched the network afterwards.Choose ERC-20
token and fill in the parameters according to your preferences. Check the boxes for Mintable
and Burnable
Press Open in Remix
Check the box for Auto compile
Injected Provider - Metamask
and connect the wallet to the website.Deploy
button and confirm the transaction in MetamaskCongratulations! We have successfully deployed our final contract!