Type-safe contract write calls (eth_sendTransaction).
Build a write call, encode it for the JS port, optionally estimate gas first.
-- Non-payable: approve
approve : Address -> BigInt -> WriteCall
approve spender amount =
writeCall
{ contract = tokenAddress
, method = "approve"
, args = [ Encode.address spender, Encode.uint256 amount ]
}
-- Payable: buy
buy : BigInt -> Wei -> WriteCall
buy minTokens value =
payableCall
{ contract = routerAddress
, method = "buy"
, args = [ Encode.uint256 minTokens ]
, value = value
}Create a non-payable write call.
Create a write call from pre-built hex calldata — the result of
Web3.Abi.Calldata.calldata. The JS port
bridge sends data directly without re-encoding.
approve : T.Address -> T.Address -> BigInt -> WriteCall
approve contract spender amount =
writeCallRaw
{ contract = contract
, data =
Calldata.calldata "095ea7b3"
[ Calldata.address spender
, Calldata.uint256 amount
]
}Create a payable write call with a value.
Create a payable write call from pre-built hex calldata + a value.
Set a gas limit.
Encode a write call as an estimateGas command for the JS port.
estimateGas myWriteCall
-- sends { tag: "estimateGas", contract: ..., method: ..., args: ..., value: ... }
-- JS responds with { tag: "gasEstimate", gas: "21000" }Encode a contract deployment for submission via the port.
Encode a raw signed transaction for broadcast via the port.
A write call to a contract.