Smart Contracts
How to interact with and configure a smart contract on the Quai Ledger.
This guide does not cover smart contract deployment. To learn more about deploying a smart contract with Quais and Hardhat, visit the Hardhat Deployment Tutorial.
Application Binary Interfaces
All operations that occur on the Quai ledger must be encoded as binary data. To call and interpret data from smart contracts on-chain, we need a simple way to convert between common data types (e.g. strings and numbers) and their binary representaion that the smart contract can understand.
Quais uses ABI fragments to encode and interpret smart contract data, allowing developers to easily pass and read data from smart contracts. There are several common formats that Quais accepts to describe a smart contract’s ABI. The Solidity compiler typically provides a JSON ABI for every compiled contract that can be passed to Quais.
You may also provide the more readable Solidity signature for any relevant methods, errors, or calls to the contract.
Read-only Interactions
Contracts often have read-only methods (view and pure) that can be called to query the state of the smart contract without initiating a transaction. You can call these methods using only a Provider.
State-changing Interactions
To call a state-changing method, you’ll need to pass a Signer or Wallet to the contract.
Events
Listening for Events
You can listen for emitted events from a smart contract using event filters.
Query Historic Events
To query historic events, you can use the queryFilter method.
Was this page helpful?