ethereumex icon indicating copy to clipboard operation
ethereumex copied to clipboard

Add documentations

Open ayrat555 opened this issue 7 years ago • 11 comments

The library is purely documented. Fix that

ayrat555 avatar Oct 16 '17 08:10 ayrat555

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.

hickscorp avatar Jan 13 '18 16:01 hickscorp

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)

hayesgm avatar Jan 15 '18 09:01 hayesgm

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

hickscorp avatar Jan 15 '18 09:01 hickscorp

@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 avatar Jun 07 '18 19:06 tzumby

@tzumby it'd be great

ayrat555 avatar Jun 08 '18 06:06 ayrat555

@ayrat555 PR is in :)

tzumby avatar Jun 11 '18 13:06 tzumby

Can we close this issue if it has been resolved?

ghbutton avatar Jul 24 '18 00:07 ghbutton

@ghbutton After adding doctests and moduledocs we can close it

ayrat555 avatar Jul 24 '18 08:07 ayrat555

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 avatar Jul 27 '18 03:07 hayesgm

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

hickscorp avatar Jul 27 '18 08:07 hickscorp

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

ayrat555 avatar Jul 27 '18 13:07 ayrat555