Application Binary Inteface (ABI) Documentation Generator For Ethereum & Co.

abidoc - application binary interface (abi) documentation generator for Ethereum & Co. (blockchain) contracts

Usage

Let's try to generate the contract abi docs for punks v1 (anno 2017):

require 'abidoc'

punks_v1    = '0x6ba6f2207e343923ba692e5cae646fb0f566db8d'

abi = ABI.read( "./abis/#{punks_v1}.json" )
buf = abi.generate_doc( title: 'Contract ABI for Punks V1' )
write_text( "./o/punks_v1.md", buf )

resulting in:


Contract ABI for Punks V1

Constructor

  • constructor()

1 Payable Function(s)

  • function buyPunk(uint256 punkIndex) payable

7 Transact Functions(s)

  • function reservePunksForOwner(uint256 maxForThisRun)
  • function withdraw()
  • function transferPunk(address to, uint256 punkIndex)
  • function offerPunkForSaleToAddress(uint256 punkIndex, uint256 minSalePriceInWei, address toAddress)
  • function offerPunkForSale(uint256 punkIndex, uint256 minSalePriceInWei)
  • function getPunk(uint256 punkIndex)
  • function punkNoLongerForSale(uint256 punkIndex)

14 Query Functions(s)

  • function name() ⇒ (string ) _readonly
  • function punksOfferedForSale(uint256 ) ⇒ (bool isForSale, uint256 punkIndex, address seller, uint256 minValue, address onlySellTo) _readonly
  • function totalSupply() ⇒ (uint256 ) _readonly
  • function decimals() ⇒ (uint8 ) _readonly
  • function imageHash() ⇒ (string ) _readonly
  • function nextPunkIndexToAssign() ⇒ (uint256 ) _readonly
  • function punkIndexToAddress(uint256 ) ⇒ (address _) _readonly
  • function standard() ⇒ (string ) _readonly
  • function balanceOf(address ) ⇒ (uint256 _) _readonly
  • function symbol() ⇒ (string ) _readonly
  • function numberOfPunksToReserve() ⇒ (uint256 ) _readonly
  • function numberOfPunksReserved() ⇒ (uint256 ) _readonly
  • function punksRemainingToAssign() ⇒ (uint256 ) _readonly
  • function pendingWithdrawals(address ) ⇒ (uint256 _) _readonly

Let's try to generate the contract abi docs for punk blocks (anno 2022):

punk_blocks = '0x58e90596c2065befd3060767736c829c18f3474c'

abi = ABI.read( "./address/#{punk_blocks}.json" )

buf =  abi.generate_doc( title: 'Contract ABI for Punk Blocks' )
write_text( "./punk_blocks.md", buf )

resulting in:


Contract ABI for Punk Blocks

Constructor

  • constructor()

1 Transact Functions(s)

  • function registerBlock(bytes _dataMale, bytes _dataFemale, uint8 _layer, string _name)

8 Query Functions(s)

  • function blocks(bytes32 ) ⇒ (uint8 layer, bytes dataMale, bytes dataFemale) _readonly
  • function getBlocks(uint256 fromID, uint256 _count) ⇒ (tuple[] _, uint256 _) _readonly
  • function index(uint256 ) ⇒ (bytes32 _) _readonly
  • function nextId() ⇒ (uint256 ) _readonly
  • function svgFromIDs(uint256[] ids) ⇒ (string _) _readonly
  • function svgFromKeys(bytes32[] attributeKeys) ⇒ (string _) _readonly
  • function svgFromNames(string[] attributeNames) ⇒ (string _) _readonly
  • function svgFromPunkID(uint256 tokenID) ⇒ (string _) _readonly

and so on.

Bonus - Awesome Contracts

See the Awesome (Ethereum) Contracts / Blockchain Services @ Open Blockchains repo. that is a cache of (ethereum) contract ABIs (application binary interfaces) and open source code (if verified / available) with auto-generated docs via abidoc & friends.

License

The scripts are dedicated to the public domain. Use it as you please with no restrictions whatsoever.

Questions? Comments?

Post them on the D.I.Y. Punk (Pixel) Art reddit. Thanks.