Common Terminologies
This refers to common & constant words or phrases that would used in the process of using this SDKs.
Common Terminologies in Ether Js
- Provider
- Signer
- Contract
Provider
A Provider (in ethers) is a class which provides an abstraction for a connection to the Ethereum Network. It provides read-only access to the Blockchain and its status.
Signer
A Signer is a class which (usually) in some way directly or indirectly has access to a private key, which can sign messages and transactions to authorize the network to charge your account ether to perform operations.
Example
// A Web3Provider wraps a standard Web3 provider, which is
// what MetaMask injects as window.ethereum into each page
const provider = new ethers.providers.Web3Provider(window.ethereum)
// MetaMask requires requesting permission to connect users accounts
await provider.send("eth_requestAccounts", []);
// The MetaMask plugin also allows signing transactions to
// send ether and pay to change state within the blockchain.
// For this, you need the account signer...
const signer = provider.getSigner()
Learn more on providers here Ether.Js Provider
Contract
A Contract is an abstraction which represents a connection to a specific contract on the Ethereum Network, so that applications can use it like a normal JavaScript object.
// You can also use an ENS name for the contract address
const daiAddress = "dai.tokens.ethers.eth";
// The ERC-20 Contract ABI, which is a common contract interface
// for tokens (this is the Human-Readable ABI format)
const daiAbi = [
// Some details about the token
"function name() view returns (string)",
"function symbol() view returns (string)",
// Get the account balance
"function balanceOf(address) view returns (uint)",
// Send some of your tokens to someone else
"function transfer(address to, uint amount)",
// An event triggered whenever anyone transfers to someone else
"event Transfer(address indexed from, address indexed to, uint amount)"
];
// The Contract object
const daiContract = new ethers.Contract(daiAddress, daiAbi, provider);
Common Terminologies in VIEM
- Client
- Transport
Client
A Client in the context of viem is similar to an Ethers.js Provider
There are three types of Clients in viem:
A Public Client which provides access to Public Actions, such as
getBlockNumberandsignMessage.A Test Client which provides access to Test Actions, such as
mineandimpersonate.
Transport
A Client is instantiated with a Transport, which is the intermediary layer that is responsible for executing outgoing requests (ie. RPC requests).
There are three types of Transports in viem:
- A HTTP Transport that executes requests via a HTTP JSON-RPC API.
- A WebSocket Transport that executes requests via a WebSocket JSON-RPC API.
- A Custom Transport that executes requests via an EIP-1193 request function