Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/quietgarden/elm-web3 is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 2.0.1 found (5 same-name repos checked); no cached copy. Use another version.
Type-safe contract read calls (eth_call).
Build a read call, encode it for the JS port, decode the response. The return type is parameterized so your decoder is checked at compile time.
import Web3.Contract.Call as Call
import Web3.Abi.Decode as Decode
import Web3.Abi.Encode as Encode
-- Read a uint256 return value
totalSupply : T.Address -> Call.ReadCall BigInt
totalSupply token =
Call.readCall
{ contract = token
, method = "totalSupply()"
, args = []
, decoder = Decode.uint256
, id = "total-supply"
}
-- Simulate a write to catch reverts before broadcasting
simulate : T.Address -> BigInt -> T.Address -> Call.ReadCall Bool
simulate router amount caller =
Call.readCall
{ contract = router
, method = "buy(uint256)"
, args = [ Encode.uint256 amount ]
, decoder = Decode.bool
, id = "sim-buy"
}
|> Call.withFrom caller
-- Send via port
web3Cmd (Call.encode (totalSupply tokenAddress))
-- Decode response
result = D.decodeValue (Call.responseDecoder myCall) incomingRelated modules: Web3.Multicall for batching multiple reads into one RPC call;
Web3.Contract.Send for write calls.
Create a read call. The id is echoed back in the response so you can
match responses to requests when multiple calls are in flight.
Set the block number for the call.
Add a from address — turns eth_call into a simulation of a write.
Catches reverts without broadcasting.
simulateBuy tokenAddress amount userAddress
|> withFrom userAddress
|> encode
|> web3CmdGet the response decoder for a read call.
A read-only contract call with a typed return value.