
Scroll.io: A Native zkEVM Scaling Solution for Ethereum
IntroEthereum is the most popular and widely used smart contract platform in the world. It enables developers to create decentralized applications (DApps) that run on a global network of nodes without intermediaries or censorship. However, Ethereum also faces some challenges, such as scalability, high gas fees, and long confirmation times. These issues limit the potential of Ethereum to support more users and use cases. To address these challenges, many projects have been working on scaling s...

ZigZag New Features on the Way
ZigZag Exchange is a decentralized orderbook exchange that uses ZK-Rollup technology to provide fast, cheap and secure trading on Ethereum. ZigZag was the first project to launch on zkSync 1.0 mainnet, now zkSync Lite, in November 202112. Since then, ZigZag has been offering its users a smooth trading experience with minimal slippage and thick orderbooks3. ZigZag also participated in one of the biggest airdrops in crypto history, rewarding its early users with ZKS tokens4.$ZZ/$USDC Market/Lim...

Smart Contracts: Get deep
What Are Smart Contracts? Smart contracts are self-executing contracts with the terms of the agreement directly written into lines of code. They are computer programs that automate the execution and enforcement of agreements between parties. Smart contracts are typically stored on a blockchain network, which ensures their transparency, security, and immutability.When certain predetermined conditions are met, smart contracts automatically execute the agreed-upon actions without the need for in...
<100 subscribers

Scroll.io: A Native zkEVM Scaling Solution for Ethereum
IntroEthereum is the most popular and widely used smart contract platform in the world. It enables developers to create decentralized applications (DApps) that run on a global network of nodes without intermediaries or censorship. However, Ethereum also faces some challenges, such as scalability, high gas fees, and long confirmation times. These issues limit the potential of Ethereum to support more users and use cases. To address these challenges, many projects have been working on scaling s...

ZigZag New Features on the Way
ZigZag Exchange is a decentralized orderbook exchange that uses ZK-Rollup technology to provide fast, cheap and secure trading on Ethereum. ZigZag was the first project to launch on zkSync 1.0 mainnet, now zkSync Lite, in November 202112. Since then, ZigZag has been offering its users a smooth trading experience with minimal slippage and thick orderbooks3. ZigZag also participated in one of the biggest airdrops in crypto history, rewarding its early users with ZKS tokens4.$ZZ/$USDC Market/Lim...

Smart Contracts: Get deep
What Are Smart Contracts? Smart contracts are self-executing contracts with the terms of the agreement directly written into lines of code. They are computer programs that automate the execution and enforcement of agreements between parties. Smart contracts are typically stored on a blockchain network, which ensures their transparency, security, and immutability.When certain predetermined conditions are met, smart contracts automatically execute the agreed-upon actions without the need for in...
Share Dialog
Share Dialog


We want to understand which of the two mentioned technologies can better meet our needs. Let's go straight to the point; Let's write a simple project with the help of both technologies and have a small comparison of them at the end.

It’s a simple project that is written in Solidity and GoLang:
A simple bank smart contract that allows users to enroll, deposit, and withdraw Ether. The contract also rewards the first three users who enroll with 10 Ether each.
The Solidity code for the smart contract is:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleBank {
// State variables
mapping(address => uint) private balances;
address[] private accounts;
uint private rewardAmount = 10 ether;
uint private numEnrolled = 0;
// Events
event LogEnrolled(address accountAddress);
event LogDepositMade(address accountAddress, uint amount);
event LogWithdrawal(address accountAddress, uint withdrawAmount, uint newBalance);
// Constructor
constructor() payable {
require(msg.value == 30 ether, "30 ether initial funding required");
}
// Modifiers
modifier onlyEnrolled() {
require(balances[msg.sender] > 0, "Not enrolled");
_;
}
// Functions
function enroll() public returns (uint) {
require(balances[msg.sender] == 0, "Already enrolled");
if (numEnrolled < 3) {
balances[msg.sender] = rewardAmount;
numEnrolled++;
}
accounts.push(msg.sender);
emit LogEnrolled(msg.sender);
return balances[msg.sender];
}
function deposit() public payable onlyEnrolled returns (uint) {
balances[msg.sender] += msg.value;
emit LogDepositMade(msg.sender, msg.value);
return balances[msg.sender];
}
function withdraw(uint withdrawAmount) public onlyEnrolled returns (uint remainingBal) {
require(withdrawAmount <= balances[msg.sender], "Insufficient balance");
balances[msg.sender] -= withdrawAmount;
payable(msg.sender).transfer(withdrawAmount);
emit LogWithdrawal(msg.sender, withdrawAmount, balances[msg.sender]);
return balances[msg.sender];
}
function balance() public view onlyEnrolled returns (uint) {
return balances[msg.sender];
}
}
The GoLang code for interacting with the smart contract is:
package main
import (
"context"
"fmt"
"log"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
simplebank "./api" // for demo
)
func main() {
client, err := ethclient.Dial("http://127.0.0.1:7545")
if err != nil {
log.Fatal(err)
}
privateKey, err := crypto.HexToECDSA("c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3") // ganache test key
if err != nil {
log.Fatal(err)
}
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*crypto.PublicKey)
if !ok {
log.Fatal("error casting public key to ECDSA")
}
fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
nonce, err := client.PendingNonceAt(context.Background(), fromAddress)
if err != nil {
log.Fatal(err)
}
gasPrice, err := client.SuggestGasPrice(context.Background())
if err != nil {
log.Fatal(err)
}
auth := bind.NewKeyedTransactor(privateKey)
auth.Nonce = big.NewInt(int64(nonce))
auth.Value = big.NewInt(30 * 1e18) // in wei
auth.GasLimit = uint64(300000) // in units
auth.GasPrice = gasPrice
address, tx, instance, err := simplebank.DeploySimpleBank(auth, client)
if err != nil {
log.Fatal(err)
}
fmt.Println(address.Hex()) // 0x147B8eb97fD247D06C4006D269c90C1908Fb5D54
fmt.Println(tx.Hash().Hex()) // 0xdae8ba5444eefdc99dbbc14b432a6c75d24b2de934d0a1686a51d76c2f758f9f
_ = instance
}
The comparison between the two codes is:
The Solidity code defines the state variables, events, constructor, modifiers, and functions of the smart contract. It also uses the pragma directive to specify the Solidity version and the SPDX license identifier. It also uses the require function to check for preconditions and the emit function to trigger events.
The GoLang code uses the ethclient package to connect to a local Ethereum node, the crypto package to generate and sign transactions, and the bind package to deploy and interact with smart contracts. It also uses the simplebank package, which is generated by abigen from the compiled Solidity contract. It also uses big.Int to represent large numbers such as wei and gas.

We want to understand which of the two mentioned technologies can better meet our needs. Let's go straight to the point; Let's write a simple project with the help of both technologies and have a small comparison of them at the end.

It’s a simple project that is written in Solidity and GoLang:
A simple bank smart contract that allows users to enroll, deposit, and withdraw Ether. The contract also rewards the first three users who enroll with 10 Ether each.
The Solidity code for the smart contract is:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleBank {
// State variables
mapping(address => uint) private balances;
address[] private accounts;
uint private rewardAmount = 10 ether;
uint private numEnrolled = 0;
// Events
event LogEnrolled(address accountAddress);
event LogDepositMade(address accountAddress, uint amount);
event LogWithdrawal(address accountAddress, uint withdrawAmount, uint newBalance);
// Constructor
constructor() payable {
require(msg.value == 30 ether, "30 ether initial funding required");
}
// Modifiers
modifier onlyEnrolled() {
require(balances[msg.sender] > 0, "Not enrolled");
_;
}
// Functions
function enroll() public returns (uint) {
require(balances[msg.sender] == 0, "Already enrolled");
if (numEnrolled < 3) {
balances[msg.sender] = rewardAmount;
numEnrolled++;
}
accounts.push(msg.sender);
emit LogEnrolled(msg.sender);
return balances[msg.sender];
}
function deposit() public payable onlyEnrolled returns (uint) {
balances[msg.sender] += msg.value;
emit LogDepositMade(msg.sender, msg.value);
return balances[msg.sender];
}
function withdraw(uint withdrawAmount) public onlyEnrolled returns (uint remainingBal) {
require(withdrawAmount <= balances[msg.sender], "Insufficient balance");
balances[msg.sender] -= withdrawAmount;
payable(msg.sender).transfer(withdrawAmount);
emit LogWithdrawal(msg.sender, withdrawAmount, balances[msg.sender]);
return balances[msg.sender];
}
function balance() public view onlyEnrolled returns (uint) {
return balances[msg.sender];
}
}
The GoLang code for interacting with the smart contract is:
package main
import (
"context"
"fmt"
"log"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
simplebank "./api" // for demo
)
func main() {
client, err := ethclient.Dial("http://127.0.0.1:7545")
if err != nil {
log.Fatal(err)
}
privateKey, err := crypto.HexToECDSA("c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3") // ganache test key
if err != nil {
log.Fatal(err)
}
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*crypto.PublicKey)
if !ok {
log.Fatal("error casting public key to ECDSA")
}
fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
nonce, err := client.PendingNonceAt(context.Background(), fromAddress)
if err != nil {
log.Fatal(err)
}
gasPrice, err := client.SuggestGasPrice(context.Background())
if err != nil {
log.Fatal(err)
}
auth := bind.NewKeyedTransactor(privateKey)
auth.Nonce = big.NewInt(int64(nonce))
auth.Value = big.NewInt(30 * 1e18) // in wei
auth.GasLimit = uint64(300000) // in units
auth.GasPrice = gasPrice
address, tx, instance, err := simplebank.DeploySimpleBank(auth, client)
if err != nil {
log.Fatal(err)
}
fmt.Println(address.Hex()) // 0x147B8eb97fD247D06C4006D269c90C1908Fb5D54
fmt.Println(tx.Hash().Hex()) // 0xdae8ba5444eefdc99dbbc14b432a6c75d24b2de934d0a1686a51d76c2f758f9f
_ = instance
}
The comparison between the two codes is:
The Solidity code defines the state variables, events, constructor, modifiers, and functions of the smart contract. It also uses the pragma directive to specify the Solidity version and the SPDX license identifier. It also uses the require function to check for preconditions and the emit function to trigger events.
The GoLang code uses the ethclient package to connect to a local Ethereum node, the crypto package to generate and sign transactions, and the bind package to deploy and interact with smart contracts. It also uses the simplebank package, which is generated by abigen from the compiled Solidity contract. It also uses big.Int to represent large numbers such as wei and gas.

No comments yet