Calling Smart Contracts with `chifra state --call`

The Commands

Using the Call Option

Install TrueBlocks

Running the Commands

chifra names ERC20 | head -614 | tail -8 | head -1
Tag             Address         Name       Symbol Decimals
50-Tokens:ERC20 0x2287b...f49bf SoundMoney SDM 18
chifra list 0x2287bd440a11c4585058fdc090455786130f49bf
  1. It visits every chunk of the TrueBlock index and finds every appearance of this address anywhere on the chain,
  2. As it does this, depending on your setup, it downloads and caches (i.e. pins on IPFS) those portions of the index that you’ve expressed interest in. In this way, you become part of the solution to making access to the Ethereum data permissionless.
  3. It caches the list of appearances so the next time you run it, it’s almost instantaneous.
chifra list 0x2287bd440a11c4585058fdc090455786130f49bf --count

Extracting and Cacheing Ethereum Data

chifra export 0x2287bd440a11c4585058fdc090455786130f49bf
time chifra export --cache_tx 0x2287b...f49bf

Using the Chifra --call Option

chifra abis 0x2287bd440a11c4585058fdc090455786130f49bf
name          four-byte   signature
totalSupply 0x18160ddd totalSupply()
chifra state --call "0x2287b...f49bf | totalSupply()"
chifra state --call "0x2287b...f49bf | totalSupply()(uint)"
chifra state --call "0x2287b...f49bf | totalSupply() returns (uint)"
bn       addr          signature     encoding    compressedresult
13496062 0x2287...49bf totalSupply() 0x18160ddd 429

All Appearances

# Store the blocks this address appears in blocks.txt
chifra list 0x2287bd440a11c4585058fdc090455786130f49bf --no_header \
| cut -f2 \
| sort -u -n >blocks.txt
# count how many unique blocks appear (we get 152 blocks)
wc blocks.txt
# Cache the extracted transactions (this is optional, but may
# speed things up

chifra export --cache_txs 0x2287bd440a11c4585058fdc090455786130f49bf
# Using the blocks.txt file call the totalSupply routine
# on the address at every block

chifra state --call \
"0x2287bd440a11c4585058fdc090455786130f49bf|totalSupply()()" \
--file blocks.txt

Support Our Work




Blockchain Enthusiast, Founder TrueBlocks, LLC and Philadelphia Ethereum Meetup, MS Computer Science UPenn

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

DeepCloud AI

Meet Maecenas — the decentralised art gallery democratising fine art investment

Distributed systems and the death/disappearance of the intermediary

DAOs and What Comes Next for the Gaming Communities

VIDT B2B & B2C NFTs on Binance Smart Chain

Meet Solar Heroes White Paper

NFTs are not just for digital art — here are some other uses for them

Vite Bi-Weekly Report

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Thomas Jay Rush

Thomas Jay Rush

Blockchain Enthusiast, Founder TrueBlocks, LLC and Philadelphia Ethereum Meetup, MS Computer Science UPenn

More from Medium

Agent Academy: Cohort 1

Developing on Golem #1 — Installing Yagna and running an example

Re-Entrancy Attack

ParserError: Multiple SPDX license identifiers found in source file.