Smart Terminal is a tool to interact with Smart Contracts and make RPC calls from a terminal command line. Even though it's focused on Web3 by wrapping libraries such as @wagmi/core, Viem and Web3Modal it can be utilized for other more general purposes by enriching the list of commands.
Latest deployment: https://smart-terminal.vercel.app/
Watch how a mintable ERC20 token is minted into the account.
Watch how we can set an amount as the allowance of spender over the caller's tokens.
Sending an ERC20 token to the TokenVault contract in order to later on claim it on Taiko chain.
Processing bridge message, claiming an ERC20 token on the destination chain.
help
address, array, asyncEcho, asyncLog, author, balance, balanceDetails, block, byteArray, clear, connectedChain, contractEvents, date, deployContract, echo, editor, encodeAbiParams, encodePacked, eval, findInSerialize, formatEther, formatUnits, fromProperty, getProof, help, inspect, isoDate, keccak256, keys, loadChains, loadJson, loadVars, log, now, parseAbiParams, parseEther, parseUnits, property, readContract, set, supportedChains, switchNetwork, toBigint, toBoolean, toHex, toNumber, toRlp, transactionReceipt, values, vars, wallet, writeContract
Returns the current wallet address.
Usage:
address
Output:
0xB3cAe61…
Returns an array with the arguments passed to the command.
Usage:
array arg1 arg2 arg3 …
Output:
[arg1, arg2, arg3, …]
Echos a message asynchronously. Check out echo command for more details.
Logs a message asynchronously. Check out log command for more details.
Shows details about the author of this shell.
Usage:
author
Output:
Francisco Ramos <jscriptcoder@gmail.com> GitHub: https://github.com/jscriptcoder LinkedIn: https://www.linkedin.com/in/jscriptcoder Medium: https://medium.com/@jscriptcoder
Returns the balance.
Usage:
balance [address=0x…] [chainId=id] [formatUnits=units] [token=0x…]
Output
0.256 ETH
Params:
- [address]: Address of balance to get back. Defaults to connected wallet
- [chainId]: Chain id to get the balance from
- [formatUnits]: Units for formatting output. Values:
ether
|gwei
|wei
- [token]: ERC20 contract address
Returns details about balance and token.
Usage:
balance balanceDetails [address=0x…] [chainId=id] [formatUnits=units] [token=0x…]
Output
{ decimals: 18, formatted: "2", symbol: "BLL", value: 2000000000000000000 }
Returns information about a block at a block number, hash or tag. Defaults to latest block.
Usage:
block [blockHash=0x…] [blockNumber=123…] [blockTag=latest] [includeTransactions=false]
Params:
- [blockHash]: The hash of the block to retrieve
- [blockNumber]: The block number of the block to retrieve
- [blockTag]: The tag of the block to retrieve. Values:
latest
|earliest
|pending
|safe
|finalized
- [includeTransactions]: If true, includes the transactions in the block
Returns an array of bytes with the arguments passed to the command.
Usage:
byteArray arg1 arg2 arg3 …
Output:
Uint8Array[arg1, arg2, arg3, …]
Clears the terminal.
Returns the chain we are currently connected to.
Usage:
connectedChain
Output:
{ id: 11155111, network: "sepolia", name: "Sepolia", nativeCurrency: { name: "Sepolia Ether", symbol: "SEP", decimals: 18 }, rpcUrls: {…}, blockExplorers: {…}, … }
Retrieves events from a contract.
Usage:
contractEvents abi=$abiJson [chainId=id] [address=0x…] [eventName=Transfer] [fromBlock=0] [toBlock=latest]
Output:
[{ address: "0x…", topics: […], data: "0x…", blockNumber: 123, transactionHash: "0x…", transactionIndex: 1, blockHash: "0x…", …, args: { msgHash: "0x…", message: {…} }, eventName: "MessageSent" }, …]
Params:
- abi: Contract's Abi as JSON. See loadJson command to import this file into a variable
- [chainId]: Forces a specific chain id for the request
- [address]: Address of the contract
- [eventName]: Name of the event to filter on
- [fromBlock]: Block number to start the filter from
- [toBlock]: Block number to end the filter at
Returns the current date in a human readable format.
Usage:
date
Output:
Sat Aug 12 2023 21:41:24 GMT+0200 (Central European Summer Time)
Deploys a contract to the network, given bytecode & constructor arguments.
Usage:
deployContract account=0x… abi=$abiJson bytecode=0x… [chainId=id] [args=$args]
Params:
- account: Owner of the contract
- abi: Contract's Abi as JSON
- bytecode: The contract's bytecode as 0x… hex string",
- [chainId]: Forces a specific chain id for the request',
- [args]: List of arguments to pass to the constructor',
Echos a value in the terminal.
Usage:
echo value
Output:
value
Opens an editor to enter data that will be evaluated as Javascript. Pressing ESC
cancels the operation. CTRL/CMD+s
closes the editor and returns the result of the evaluation.
Usage:
editor > result
({
name: 'Fran',
profession: 'Software Enginner',
timestamp: Date.now(),
})
// CTRL+s
Output (in variable result
):
{ name: "Fran", profession: "Software Enginner", timestamp: 1691869299389 }
Generates ABI encoded data using the ABI specification, given a set of ABI parameters (inputs/outputs) and their corresponding values.
Usage:
encodeAbiParams $abiParams $values
Params:
- abiParams: Array of ABI parameters (inputs/outputs). Example:
[{ "name": "amount", "type": "uint256" }]
- values: Array of values to encode. Example:
[ 123456 ]
Generates ABI non-standard packed encoded data given a set of solidity types compatible with packed encoding.
Usage:
encodePacked $listOfTypes $listOfValues
Params:
- listOfTypes: List of solidity types compatible with packed encoding. Example:
['address', 'string', 'bytes16[]']
- listOfValues: List of values to encode. Example:
['0x123…', 'Hello world', ['0x123…', '0x456…']]
Evaluates a JavaScript expression between double quotation.
Usage:
eval expression
eval "2 + 2" # outputs 4
eval "[1, 2, 3]" # outputs the array
eval "({name: 'Fran', age: 44})" # outputs the object
eval expression > varName # Sends the result to a variable for later use
Finds objects where the serilized version includes the string passed as parameter.
Usage:
findInSerialize stringToFind $objects
Params:
- stringToFind: String to find in the array of objects
- objects: Array of objects to search in
Converts numerical wei to a string representation of ether.
Usage:
formatEther 1000000000000000000
Output:
1
Params:
- value: The wei value
Divides a number by a given exponent of base 10, and formats it into a string representation of the number.
Usage:
formatUnits 420000000000 9
Output:
420
Params:
- value: BigNumber to format as a string, number or bigint
- decimals: Exponent of base 10
Returns an array with the values of a property in an array of objects.
Usage:
fromProperty pathToProp $objects
Params:
- pathToProp: Path to the property to get. Example:
prop1.prop2.prop3
- objects: Array of objects to get the property from
Returns the account and storage values, including the Merkle proof, of the specified account.
Usage:
getProof address=0x… storageKeys=["0x…"] block=0x…
Output:
TODO
Params:
- address: The address of the account for which the balance is to be checked
- storageKeys: An array of storage-keys that should be proofed and included
- block: A hexadecimal block number, or the string
latest
orearliest
Shows available commands or help about a specific command.
Usage:
help [command]
Params:
- [command]: Command to get help for
Helps to visualize objects rather than printing [object Object]
.
Usage:
inspect $object
Output:
{ "prop1": value1, "prop2": [value2, value3, …], "prop2": { "subprop": value4, … }, … }
Returns the current date in ISO format.
Usage:
isoDate
Output:
2023-08-12T19:42:10.598Z
Calculates the <a href="https://en.wikipedia.org/wiki/SHA-3"target="_blank">Keccak256 hash of a byte array or hex value.
Usage:
keccak256 0x123
Output:
0x667d3611…
Returns the keys of an object as array.
Usage:
keys $object
Output:
[key1, key2, key3, …]
Loads custom chains from a JSON file, sending the parsed json into localStorage and refreshing the app. The new chains will be loaded from the storage and be included in the web3 libs initialzation.
Usage:
loadChains
Loads a JSON file, which can be added into a variable.
Usage:
loadJson > $parsedJson
Loads a JSON file with variables, loading those variables into memory. See (vars)[#vars] command to list available variables.
Usage:
loadVars
Logs a value in the console.
Usage:
log value
Console:
value
Returns the current date in milliseconds.
Usage:
now
Output:
1691869299389
Parses human-readable ABI parameters into AbiParameters. Re-exported from ABIType
Usage:
parseAbiParams "address from, address to, uint256 amount"
Output:
[{ type: "address", name: "from" }, { type: "address", name: "to" }, { type: "uint256", name: "amount" }]
Params:
- params: Human-readable ABI parameters as string
Converts a string representation of ether to numerical wei.
Usage:
parseEther 420
Output:
420000000000000000000n
Params:
- value: String representation of ether
Multiplies a string representation of a number by a given exponent of base 10.
Usage:
parseUnits 420 9
Output:
420000000000n
Params:
- value: String representation of a number
- decimals: Exponent of base 10
Returns the value of a property in an object.
Usage:
property pathToProp $object
Params:
- pathToProp: Path to the property to get. Example:
prop1.prop2.prop3
- object: Object to get the property from
Calls a read-only function on a contract, returning data.
Usage:
readContract address=0x… abi=$abiJson functionName=balanceOf [chainId=id] [args=$args]
Params: address: Address of the contract abi: Contract's Abi as JSON. See loadJson command to import this file into a variable functionName: A function to extract from the ABI and call [chainId]: Forces a specific chain id for the request [args]: List of arguments to pass to the function
Can be used to set a variable.
Usage:
set value > varName
Returns an array of supported chains.
Usage:
supportedChains
Output:
[{ id: 11155111, network: "sepolia", name: "Sepolia", nativeCurrency: { name: "Sepolia Ether", symbol: "SEP", decimals: 18 }, rpcUrls: {…}, blockExplorers: {…}, … }, {…}, …]
Switches to a different chain. Chain must be supported. You can list the supported chain ids by typing supportedChains | fromProperty id
Converts a string to a BigInt.
Converts a string to a Boolean.
Encodes a string, number, boolean or byte array to a hex value value.
Usage:
toHex 420 # 0x1a4
toHex "Hello world" # 0x48656c6c6f20776f726c642e
toHex true # 0x1
Converts a string to a Number.
Encodes a hex value or byte array into a Recursive-Length Prefix (RLP) encoded value.
Usage:
toRlp 0x123456789 # 0x850123456789
toRlp ["0x7f", "0x7f", "0x8081e8"] # 0xc67f7f838081e8
Waits for a transaction to be mined, and returns the receipt.
Usage:
transactionReceipt $txHash
Output:
{ blockHash: "0x…" blockNumber: 123… contractAddress: "0x…" …, status: "success", to: "0x…", transactionHash: "0x…", transactionIndex: 1, type: "eip1559" … }
Params:
- txHash: Transaction hash to wait for. Example
Returns the values of an object as array.
Usage:
values $object
Output:
[value1, value2, value3, …]
Shows available variables.
Usage:
vars
Output:
varName1, varName2, varName3, …
Connects your wallet or opens the wallet modal if already connected.
Usage:
wallet [option]
Params:
- [option] => Option to open a specific modal. Values:
help
|account
|connect
|network
Calls a write function on a contract and returns the transaction hash.
Usage:
writeContract address=0x… abi=$abiJson functionName=contractMethod [args=$args]
Params:
- address: Address of the contract
- abi: Contract's Abi as JSON. See loadJson command to import this file into a variable
- functionName: A function to extract from the ABI and call
- [args]: List of arguments to pass to the function
Once you've created a project and installed dependencies with npm install
(or pnpm install
or yarn
), start a development server:
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
To create a production version of your app:
npm run build
You can preview the production build with npm run preview
.
To deploy your app, you may need to install an adapter for your target environment.