mana-ethereum / ethereumex

Elixir JSON-RPC client for the Ethereum blockchain 0x063D3d782598744AF1252eBEaf3aA97D990Edf72
MIT License
377 stars 73 forks source link

Add documentations #11

Open ayrat555 opened 7 years ago

ayrat555 commented 7 years ago

The library is purely documented. Fix that

hickscorp commented 6 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.

hayesgm commented 6 years ago

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)
hickscorp commented 6 years ago

That would be most helpful indeed - and IMO small things like this are the only roadblock preventing more exposure of this great library.

tzumby commented 6 years ago

@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.

ayrat555 commented 6 years ago

@tzumby it'd be great

tzumby commented 6 years ago

@ayrat555 PR is in :)

ghbutton commented 6 years ago

Can we close this issue if it has been resolved?

ayrat555 commented 6 years ago

@ghbutton After adding doctests and moduledocs we can close it

hayesgm commented 6 years ago

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.

hickscorp commented 6 years ago

@hayesgm I usually go for module doc for such examples. Maybe that's the way to go.

ayrat555 commented 6 years ago

Good point, Geoff. I think just descriptions for methods and their params would be nice