Calling Smart Contracts with `chifra state --call`

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
chifra list 0x2287bd440a11c4585058fdc090455786130f49bf --count
chifra export 0x2287bd440a11c4585058fdc090455786130f49bf
time chifra export --cache_tx 0x2287b...f49bf
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
# 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



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