Open ayrat555 opened 7 years ago
It'd be nice to add a small paragraph in the docs on how to use the lib to perform smart contracts method calls, given a JSON ABI.
Sure, I'll work on adding this to the README, but for those curious, it'll be something like this:
Add https://hex.pm/packages/blockchain and https://hex.pm/packages/abi
abi_encoded_data = ABI.encode("baz(uint,address)", [50, <<1::160>> |> :binary.decode_unsigned])
transaction_data = %Blockchain.Transaction{
data: abi_encoded_data,
gas_limit: 100_000,
gas_price: 16_000_000_000,
init: <<>>,
nonce: 5,
to: <<>>,
value: 0
}
|> Blockchain.Transaction.Signature.sign_transaction(private_key)
|> Blockchain.Transaction.serialize()
|> ExRLP.encode()
|> Base.encode16(case: :lower)
Ethereumex.HttpClient.eth_send_raw_transaction("0x" <> transaction_data)
That would be most helpful indeed - and IMO small things like this are the only roadblock preventing more exposure of this great library.
@hayesgm did you get a chance to add that snipped to the README ? I went through a similar process to get the eth_call working. I can submit a PR with the docs and include your snippet as well.
@tzumby it'd be great
@ayrat555 PR is in :)
Can we close this issue if it has been resolved?
@ghbutton After adding doctests and moduledocs we can close it
Would doctests be difficult since they are pretty side-effecting? Doctests are great for pure functions, but they aren't as clean for impure code.
@hayesgm I usually go for module doc for such examples. Maybe that's the way to go.
Good point, Geoff. I think just descriptions for methods and their params would be nice
The library is purely documented. Fix that