Skip to content

Instantly share code, notes, and snippets.

@PaulRBerg
Created September 5, 2025 19:34
Show Gist options
  • Select an option

  • Save PaulRBerg/528080f9235cbe2dd659fc32fb6653ab to your computer and use it in GitHub Desktop.

Select an option

Save PaulRBerg/528080f9235cbe2dd659fc32fb6653ab to your computer and use it in GitHub Desktop.
Shell function to copy an ABI from Foundry output directory
# Copy the ABI of a contract from the out directory to the clipboard
# Example: foundry_copy_abi SablierLockup out-optimized
function foundry_copy_abi() {
if [ -z "$1" ]; then
echo "Please provide a contract name"
echo "Usage: foundry_copy_abi <ContractName> [outDir]"
return 1
fi
local contract_name=$1
local out_dir="${2:-out}"
local json_path="${out_dir}/${contract_name}.sol/${contract_name}.json"
if [ ! -f "$json_path" ]; then
echo "Error: Could not find JSON file at $json_path"
return 1
fi
jq -r '.abi' "$json_path" | pbcopy
echo "ABI for $contract_name has been copied to clipboard"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment