ETHContract v0.1.0 EthContract
Provides a few convenience methods for getting information about tokens from ETH smart contracts. Uses JSON-RPC for requests.
Link to this section Summary
Functions
Get the balance given a wallet address. This was tested against ERC20 and ERC721 standard contracts
ERC721 Meta. This will return a Map with the meta information associated with a token. You have to provide the name of the method to use (ie. CryptoKitties uses getKitty)
Get the wallet address given a contract and a token id
Parses abi into a map
Get the total supply given a contract address. This was tested against ERC20 and ERC721 standard contracts
Link to this section Functions
Get the balance given a wallet address. This was tested against ERC20 and ERC721 standard contracts.
Examples
iex> EthContract.balance_of(%{address: '0x123', contract: '0x234'})
2
ERC721 Meta. This will return a Map with the meta information associated with a token. You have to provide the name of the method to use (ie. CryptoKitties uses getKitty)
Examples
iex> abi = EthContract.parse_abi("crypto_kitties.json")
iex> EthContract.meta(%{token_id: 45, method: "getKitty", contract: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d", abi: abi})
%{ "birthTime" => 1511417999,
"cooldownIndex" => 0,
"generation" => 0,
"genes" => 626837621154801616088980922659877168609154386318304496692374110716999053,
"isGestating" => false,
"isReady" => true,
"matronId" => 0,
"nextActionAt" => 0,
"sireId" => 0,
"siringWithId" => 0
}
Get the wallet address given a contract and a token id
Examples
iex> EthContract.owner_of(%{token_id: 1, contract: '0x123'})
Parses abi into a map.
Examples
iex> abi = EthContract.parse_abi("crypto_kitties.json")
Get the total supply given a contract address. This was tested against ERC20 and ERC721 standard contracts.
Examples
iex> EthContract.total_supply(%{contract: '0x234'})