Understand how to best use system contracts on Abstract.
When building smart contracts on Abstract, you often need to interact directly with system contracts to perform operations, such as:
To use system contracts into your smart contracts, install the @matterlabs/zksync-contracts package.
forge install matter-labs/era-contracts
Then, import the system contracts into your smart contract:
A set of libraries also exist alongside the system contracts to help you interact with them more easily.
Name | Description |
---|---|
EfficientCall.sol | Perform ultra-efficient calls using zkEVM-specific features. |
RLPEncoder.sol | Recursive-length prefix (RLP) encoding functionality. |
SystemContractHelper.sol | Library used for accessing zkEVM-specific opcodes, needed for the development of system contracts. |
SystemContractsCaller.sol | Allows calling contracts with the isSystem flag. It is needed to call ContractDeployer and NonceHolder. |
TransactionHelper.sol | Used to help custom smart contract accounts to work with common methods for the Transaction type. |
UnsafeBytesCalldata.sol | Provides a set of functions that help read data from calldata bytes. |
Utils.sol | Common utilities used in Abstract system contracts. |
View all the source code for the system contract libraries.
Each transaction can contain an isSystem
flag that indicates whether the transaction
intends to use a system contract’s functionality. Specifically, this flag needs to be true
when interacting with the ContractDeployer
or the NonceHolder system contracts.
To make a call with this flag, use the SystemContractsCaller
library, which exposes functions like systemCall
, systemCallWithPropagatedRevert
, and systemCallWithReturndata
.
Example transaction using the isSystem flag
You can also enable the isSystem
flag for your smart contract development environment.
Add enableEraVMExtensions: true
within the settings
object of the zksolc
object in the hardhat.config.js
file.
View Hardhat configuration
Add the is_system = true
flag to the foundry.toml
configuration file.
View Foundry configuration
Understand how to best use system contracts on Abstract.
When building smart contracts on Abstract, you often need to interact directly with system contracts to perform operations, such as:
To use system contracts into your smart contracts, install the @matterlabs/zksync-contracts package.
forge install matter-labs/era-contracts
Then, import the system contracts into your smart contract:
A set of libraries also exist alongside the system contracts to help you interact with them more easily.
Name | Description |
---|---|
EfficientCall.sol | Perform ultra-efficient calls using zkEVM-specific features. |
RLPEncoder.sol | Recursive-length prefix (RLP) encoding functionality. |
SystemContractHelper.sol | Library used for accessing zkEVM-specific opcodes, needed for the development of system contracts. |
SystemContractsCaller.sol | Allows calling contracts with the isSystem flag. It is needed to call ContractDeployer and NonceHolder. |
TransactionHelper.sol | Used to help custom smart contract accounts to work with common methods for the Transaction type. |
UnsafeBytesCalldata.sol | Provides a set of functions that help read data from calldata bytes. |
Utils.sol | Common utilities used in Abstract system contracts. |
View all the source code for the system contract libraries.
Each transaction can contain an isSystem
flag that indicates whether the transaction
intends to use a system contract’s functionality. Specifically, this flag needs to be true
when interacting with the ContractDeployer
or the NonceHolder system contracts.
To make a call with this flag, use the SystemContractsCaller
library, which exposes functions like systemCall
, systemCallWithPropagatedRevert
, and systemCallWithReturndata
.
Example transaction using the isSystem flag
You can also enable the isSystem
flag for your smart contract development environment.
Add enableEraVMExtensions: true
within the settings
object of the zksolc
object in the hardhat.config.js
file.
View Hardhat configuration
Add the is_system = true
flag to the foundry.toml
configuration file.
View Foundry configuration