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

Matrixswap Joins Forces with Cardano Wallet Solution, CardWallet

Triassic Solutions — End-to-End Product Development | Digital Transformation | Industrial…

Crypto Unicorns Integrates Chainlink VRF to Help Power Random In-Game Rewards

[At Stake] — Highlighting Everything PoS

Dreamster Acknowledges Offering A Refined Experience To Explore NFTs

A Well-known Hero in The Making

Gas and Payment — Ethereum Yellow Paper Walkthrough (3/7)

HR Calling: A Decentralised Professional Passport

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

Introducing Owlracle: A multichain gas price tracker API

Owlracle, a multichain gas price tracker API

zkMove at a Glance

Airtrace 3.0 — Understanding Hyperledger Besu, the technology on the rise.

IPFS&Fliecoin economic incentive model