Poke: A CLI tool for Ethereum Development
By: Taylor Brent
Tags: Ethereum, Software Development, Cli, Updates, Stable Coin

Today we are pleased to announce we are open sourcing a tool that we have found useful for simplifying Ethereum development. We hope you like it.

Meet poke

What is Poke?

poke dynamically generates a command-line interface at runtime for your smart contracts. We know that doesn’t sound sexy, but hold on a minute…

You only need one CLI tool for all your smart contract interaction

You don’t have to think about bytecode

You don’t have to think about ABIs

Everything just works

With poke , you can go right from writing Solidity to deploying and interacting with your smart contract within seconds.

Why Poke?

If you give a child a new object, what happens? Well, they start poking at it of course…and putting it in their mouth…and throwing it across the room…and all sorts of other crazy things. But all these behaviors have something in common: they provide feedback, and they provide it FAST.

This example is ridiculous, of course, but it does illustrate an important point: the process of quickly understanding is composed of questions and answers, and preferably, lots of them. Maybe interacting with software isn’t so different.

What does Poke do?

Now for the nitty gritty…

First, poke compiles your .sol file and any dependencies it has to create the corresponding bytecode and ABI, which it stores in a hidden cache for use next time.

Next, poke processes the ABI and creates a cobra CLI tool, all on the fly. It’s sort of like factory, but instead of creating a new CLI tool for you, it just changes itself during runtime to adapt to whatever smart contract it’s currently working with. Here’s what it looks like when you call poke without any commands:

the result of using poke on our RSR token. See: https://etherscan.io/address/0x8762db106b2c2a0bccb3a80d1ed41273552616e8#contracts

If you write a new function for your smart contract, it will automatically appear here. No extra work required! Everything happens at runtime.

Here’s a breakdown of the sections:

In the top section, poke creates commands that allow us to read out the state of the contract. In the middle section, poke creates commands for each of the functions in our smart contract. For example, we locked all our own tokens by calling the lockMyTokensForever function. We do not recommend you do the same! (Note: Comments from the solidity file are pulled in as command descriptions automatically. Shame on us for commenting so sparsely here) At the bottom, we have a set of utility functions. These functions are always provided to the user, regardless of what smart contract you’re working with. deploy is extremely useful. Lastly, there are a few flags that we added just to complicate things, but you’ll be glad you have them. Most importantly, the -n flag allows you to specify the url of the node you’d like to interact with. This allows you to seamlessly switch between a local dev chain, testnet, and mainnet. You can also pass -F hardware in order to use a Trezor or Ledger Nano.

One tip we have for people is that poke pairs extremely well with aliases. So, for example, say you’re working with a few different smart contracts. One option is to declare a few aliases for yourself such as:

alias rsr='SOLC_VERSION=0.4.24 poke /path/to/ReserveRights.sol -c ReserveRightsToken'

This enables you to do things like rsr pause or rsr transfer from anywhere in your file system.

That’s about it! If you’d like to contribute or use the tool yourself, you can find it in our Github repository, https://github.com/reserve-protocol/poke