Network
Launch Date
Consensus
Note
Sepolia
Oct 2021
PoW
Like-for-like representation of Ethereum
Görli
Jan 2019
PoA
Proof-of-Authority
Kiln
Mar 2022
PoS
Post-Merge (for ETH2), shadow fork of the mainnet
Kintsugi
Dec 2021
PoS
DEPRECATED, use Kiln; post-Merge (for ETH2)
Ropsten
Nov 2016
PoW
DEPRECATED, use Sepolia; the Merge to happen on Jun 8, 2022
Rinkeby
Apr 2017
PoA
DEPRECATED, use Görli and Görli Faucet
Kovan
Mar 2017
PoA
DEPRECATED, use Sepolia or Görli
List of active and deprecated Ethereum testnets, including Kintsugi.
Features
Optimistic rollup 
ZK-rollup 
Proof
Uses fraud proofs to prove transaction validity. 
Uses validity (zero-knowledge) proofs to prove transaction validity. 
Capital efficiency
Requires waiting through a 1-week delay (dispute period) before withdrawing funds. 
Users can withdraw funds immediately because validity proofs provide incontrovertible evidence of the authenticity of off-chain transactions. 
Data compression
Publishes full transaction data as calldata to Ethereum Mainnet, which increases rollup costs. 
Doesn't need to publish transaction data on Ethereum because ZK-SNARKs and ZK-STARKs already guarantee the accuracy of the rollup state. 
EVM compatibility
Uses a simulation of the Ethereum Virtual Machine (EVM), which allows it to run arbitrary logic and support smart contracts. 
Doesn't widely support EVM computation, although a few EVM-compatible ZK-rollups have appeared. 
Rollup costs
Reduces costs since it publishes minimal data on Ethereum and doesn't have to post proofs for transactions, except in special circumstances. 
Faces higher overhead from costs involved in generating and verifying proofs for every transaction block. ZK proofs require specialized, expensive hardware to create and have high on-chain verification costs. 
Trust assumptions
Doesn't require a trusted setup. 
Requires a trusted setup to work. 
Liveness requirements
Verifiers are needed to keep tabs on the actual rollup state and the one referenced in the state root to detect fraud. 
Users don't need someone to watch the L2 chain to detect fraud. 
Security properties 
Relies on cryptoeconomic incentives to assure users of rollup security. 
Relies on cryptographic guarantees for security. 
Start building
on Alchemy.
Sign up for free
Start building on Optimism.
Sign up for free
Start building on Arbitrum.
Sign up for free
Start building on Ethereum.
Sign up for free
Start building on Polygon.
Sign up for free
Start building on Starknet.
Sign up for free
Start building on Flow.
Sign up for free
kiln faucet
Get free Kiln ETH.
Start building today
Goerli faucet
Get free Goerli ETH.
Start building today
mumbai faucet
Get free Mumbai Matic.
Start building today
rinkeby faucet
Get free Rinkeby
ETH.
Start building today
Start building on Ethereum.
Get started for free
Start building on Ethereum.
Get started for free
Start building on Flow.
Get started for free
Start building on Polygon.
Get started for free
Start building on Starknet.
Get started for free
Start building on Optimism.
Get started for free
Start building on Solana.
Get started for free
Start building on Solana.
Sign up for beta access
Start building on Solana.
Join the waitlist
Arbitrum logo
Start building on Arbitrum.
Get started for free
Learn
Solidity at
Alchemy
University
Get started today
curl 
https://release.solana.com/v1.10.32/solana-install-init-x86_64-pc-windows-msvc.exe 
--output 
C:\solana-install-tmp\solana-install-init.exe 
--create-dirs
Learn Solidity
CALLING CONTRACTS OVERVIEW

How to Call Another Contract Using Solidity

Reasons to Call Another Smart Contract and Examples
Last Updated:
October 4, 2022
Table of Contents
Table of Contents
Table of Contents

{{learn-solidity}}

It is possible on Solidity to create smart contracts that borrow functions of other contracts. We call the smart contract that does the borrowing the caller smart contract and the smart contract whose function is borrowed the called smart contract.

This article will explain when developers should call another contract and a tutorial through example code.

Why Call Another Contract

One of the biggest advances that Ethereum brought to blockchains was the ability to upload and compute code on-chain. Once these programs, known as smart contracts, are uploaded to the blockchain, they cannot be edited. Anyone can view them and, if coded right, they can be interacted with by smart contracts, even if their owners do not know one another, effectively turning smart contracts into reusable libraries. A smart contract whose owner intended its code to be used for one purpose can be reused by thousands of others for their own use cases via calling.

Another reason that people call other smart contracts is because while programming, their original smart contract reached the size limitation of 24,577 bytes before completion. To workaround this, developers move enough of the functions to a new smart contract such that they are below the byte limit. 

Calling Another Smart Contract Example

We have created two example smart contracts below to teach you how one contract can call another smart contract.

Call Contract And Update Values

In this first contract, the value contained in CalledContract is updated by the CallerContract.



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract CallerContract{
	function setX(address _address, uint_ x) external{
	CalledContract(_address).setX(_x);
	}
}

contract CalledContract{
	uint public x
	unit public value = 123;
	function setX(uint _x) external {
		x = _x;
	}
}

Sending ETH with a Call

In this second contract, not only is the x value in CalledContractReceivesEther updated by CallerContractAndSendEther, but ETH will also be sent with the call.



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract CallerContractAndSendEther{
	function setXAndReceiveEther(address _address, uint_ x) external     payable {
CalledContractReceivesEther(_address).receiveXandreceiveEther{value: _value}(_x);
	}

contract CalledContractReceivesEther{
	Uint public x
	Unit public value = 123;
	function receiveXandreceiveEther(uint _x) external payable {
      x = _x;
      value = msg.value;
      }
}

How to learn more about Solidity 

Want to learn more Solidity? With the recent acquisition of ChainShot, a Solidity education platform, Alchemy University is offering a 7-week Ethereum developer crash course, originally a $3,000 certification bootcamp, for free to the public. Secure your spot today!

If you are new to development in general, Alchemy's 3-week JavaScript crash course is a great prerequisite before starting an Ethereum bootcamp.

ALCHEMY SUPERNODE - ETHEREUM NODE API

Scale to any size, without any errors

Alchemy Supernode finally makes it possible to scale blockchain applications without all the headaches. Plus, our legendary support will guide you every step of the way.

Get started for free
Supernode footer
Learn Solidity
CALLING CONTRACTS OVERVIEW

How to Call Another Smart Contract On Ethereum

Reasons to Call Another Smart Contract and Examples
Last Updated:
October 4, 2022
Don't miss an update
Sign up for our newsletter to get alpha, key insights, and killer resources.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Table of Contents
Table of Contents

{{learn-solidity}}

It is possible on Solidity to create smart contracts that borrow functions of other contracts. We call the smart contract that does the borrowing the caller smart contract and the smart contract whose function is borrowed the called smart contract.

This article will explain when developers should call another contract and a tutorial through example code.

Why Call Another Contract

One of the biggest advances that Ethereum brought to blockchains was the ability to upload and compute code on-chain. Once these programs, known as smart contracts, are uploaded to the blockchain, they cannot be edited. Anyone can view them and, if coded right, they can be interacted with by smart contracts, even if their owners do not know one another, effectively turning smart contracts into reusable libraries. A smart contract whose owner intended its code to be used for one purpose can be reused by thousands of others for their own use cases via calling.

Another reason that people call other smart contracts is because while programming, their original smart contract reached the size limitation of 24,577 bytes before completion. To workaround this, developers move enough of the functions to a new smart contract such that they are below the byte limit. 

Calling Another Smart Contract Example

We have created two example smart contracts below to teach you how one contract can call another smart contract.

Call Contract And Update Values

In this first contract, the value contained in CalledContract is updated by the CallerContract.



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract CallerContract{
	function setX(address _address, uint_ x) external{
	CalledContract(_address).setX(_x);
	}
}

contract CalledContract{
	uint public x
	unit public value = 123;
	function setX(uint _x) external {
		x = _x;
	}
}

Sending ETH with a Call

In this second contract, not only is the x value in CalledContractReceivesEther updated by CallerContractAndSendEther, but ETH will also be sent with the call.



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract CallerContractAndSendEther{
	function setXAndReceiveEther(address _address, uint_ x) external     payable {
CalledContractReceivesEther(_address).receiveXandreceiveEther{value: _value}(_x);
	}

contract CalledContractReceivesEther{
	Uint public x
	Unit public value = 123;
	function receiveXandreceiveEther(uint _x) external payable {
      x = _x;
      value = msg.value;
      }
}

How to learn more about Solidity 

Want to learn more Solidity? With the recent acquisition of ChainShot, a Solidity education platform, Alchemy University is offering a 7-week Ethereum developer crash course, originally a $3,000 certification bootcamp, for free to the public. Secure your spot today!

If you are new to development in general, Alchemy's 3-week JavaScript crash course is a great prerequisite before starting an Ethereum bootcamp.

It is possible on Solidity to create smart contracts that borrow functions of other contracts. We call the smart contract that does the borrowing the caller smart contract and the smart contract whose function is borrowed the called smart contract.

This article will explain when developers should call another contract and a tutorial through example code.

Why Call Another Contract

One of the biggest advances that Ethereum brought to blockchains was the ability to upload and compute code on-chain. Once these programs, known as smart contracts, are uploaded to the blockchain, they cannot be edited. Anyone can view them and, if coded right, they can be interacted with by smart contracts, even if their owners do not know one another, effectively turning smart contracts into reusable libraries. A smart contract whose owner intended its code to be used for one purpose can be reused by thousands of others for their own use cases via calling.

Another reason that people call other smart contracts is because while programming, their original smart contract reached the size limitation of 24,577 bytes before completion. To workaround this, developers move enough of the functions to a new smart contract such that they are below the byte limit. 

Calling Another Smart Contract Example

We have created two example smart contracts below to teach you how one contract can call another smart contract.

Call Contract And Update Values

In this first contract, the value contained in CalledContract is updated by the CallerContract.



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract CallerContract{
	function setX(address _address, uint_ x) external{
	CalledContract(_address).setX(_x);
	}
}

contract CalledContract{
	uint public x
	unit public value = 123;
	function setX(uint _x) external {
		x = _x;
	}
}

Sending ETH with a Call

In this second contract, not only is the x value in CalledContractReceivesEther updated by CallerContractAndSendEther, but ETH will also be sent with the call.



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract CallerContractAndSendEther{
	function setXAndReceiveEther(address _address, uint_ x) external     payable {
CalledContractReceivesEther(_address).receiveXandreceiveEther{value: _value}(_x);
	}

contract CalledContractReceivesEther{
	Uint public x
	Unit public value = 123;
	function receiveXandreceiveEther(uint _x) external payable {
      x = _x;
      value = msg.value;
      }
}

How to learn more about Solidity 

Want to learn more Solidity? With the recent acquisition of ChainShot, a Solidity education platform, Alchemy University is offering a 7-week Ethereum developer crash course, originally a $3,000 certification bootcamp, for free to the public. Secure your spot today!

If you are new to development in general, Alchemy's 3-week JavaScript crash course is a great prerequisite before starting an Ethereum bootcamp.

Build web3 with Alchemy

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get started for free