ETHContract v0.2.4 EthContract behaviour
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
Decodes general smart contract calls
Decodes events with no indexes
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 with the name of the method as key
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
Decodes general smart contract calls
Decodes events with no indexes.
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("test/support/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: "0x06012c8cf97bead5deae237070f9587f8e7a266d"})
0x79bd592415ff6c91cfe69a7f9cd091354fc65a18
Parses abi into a map with the name of the method as key.
Examples
iex> abi = EthContract.parse_abi("test/support/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'})
:ok