ethio: add +read-contract for chain state reading

This commit is contained in:
Fang 2019-10-31 19:25:57 +01:00 committed by Jared Tobin
parent 82e25e3940
commit e402cbc550
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4

View File

@ -102,4 +102,17 @@
=, dejs-soft:format
(ot id+so error+(ot code+no message+so ~) ~)
--
:: +read-contract: calls a read function on a contract, produces result hex
::
++ read-contract
|= [url=@t proto-read-request:rpc:ethereum]
=/ m (async:stdio ,@t)
;< =json bind:m
%^ request-rpc url id
:+ %eth-call
^- call:rpc:ethereum
[~ to ~ ~ ~ `tape`(encode-call:rpc:ethereum function arguments)]
[%label %latest]
?. ?=(%s -.json) (async-fail:stdio %request-rpc-fail >json< ~)
(pure:m p.json)
--