Published on

How I used Raycast to automate searching addresses on Etherscan

Authors

From the past 2years, I’ve been dabbling in developing contracts and scripts on the Ethereum and EVM based blockchains.

As any blockchain developer would say, our Swiss Army knife is the block-explorer we use to peek at contracts and stalk fellow degens whose addresses are public on twitter.

But when you’re building any dApp / protocol that is cross-chain, you have to constantly switch between so many block-explorers for each chain and constantly have to:

  1. Open a new tab
  2. Type in the block explorer link
  3. Enter the address you wanna peak
  4. Press Enter / Click on the search button

It takes 4 steps, which is a lot of unnecessary friction, when you are thinking about so many things and are constantly context switching. Especially if you have a very busy schedule.

Since most of my readers and followers are productivity buffs and automatooors, I don’t need to sell y’all on the need to eliminate this friction by automating it. This will not only save you some precious keystrokes and time but also the stress/energy involved while regular context switching.

So without further ado let’s begin, I use a really cool spotlight alternative on my mac called Raycast. It has many plugins and can automate so many things for you, from searching for GIFs to joining the google meet on your calendar, with just 1 step which is ⌘+Space.

The coolest thing about it is that it’s very extensible and I can write my own extensions for it very easily and so I did. Here’s a quick demo of what my extension does:

So all you have to do is:

Open Raycast, press E followed by the address you want to open and press Enter and boom the block explorer opens in a new tab!

Here’s the code for it:

#!/usr/bin/env node

// Required parameters:
// @raycast.schemaVersion 1
// @raycast.title Etherscan
// @raycast.mode silent

// Optional parameters:
// @raycast.icon images/eth-logo.png
// @raycast.argument1 { "type": "text", "placeholder": "Hash" }
// @raycast.argument2 { "type": "text", "placeholder": "Network", "optional": true, "percentEncoded": true }
const [address, networkAlias] = process.argv.slice(2)
const open = require('open')
const aliases = {
  m: 'etherscan.io',
  g: 'goerli.etherscan.io',
  k: 'kovan.etherscan.io',
  ro: 'ropsten.etherscan.io',
  ri: 'rinkeby.etherscan.io',
  p: 'polygonscan.com',
  pm: 'mumbai.polygonscan.com',
  f: 'ftmscan.com',
  a: 'snowtrace.io',
  b: 'bscscan.com',
}

/// @dev use the network alias, if not available, then use mainnet.
const domain = aliases[networkAlias] || aliases['m']

const url = `https://${domain}/search?f=0&q=${address}`

open(url)

Of course, if you are searching on networks other than the ones mentioned above you can feel free to tweak the aliases key/value pair.

I would love to know if you end up using it, because then I know there is a need and that would be push me towards publishing a better version over their extension store!