External Interfaces
Ethereum ABI Export
Add export = eth to make a method visible through the current Ethereum ABI export path.
#[method::network(export = eth)]
fn balanceOf(ctx: &_, account: Address) -> LyquidResult<U256> {
Ok(*ctx.network.balances.get(&account).unwrap_or(&U256::ZERO))
}
#[method::instance(export = eth)]
fn local_status(ctx: &_) -> LyquidResult<String> {
Ok(format!("node={}", ctx.node_id))
}
The proc macro emits export metadata into the lyquor.method.export.eth custom section. The runtime
uses that metadata to expose the method as an ETH-compatible contract method.
Export metadata records:
- method category: network or instance
- mutability from the context reference
- group name
- method name
- parameter ABI types
- return ABI types
ETH ABI Types
The current EthAbiType implementations include:
| Rust type | ETH ABI type |
|---|---|
U256 | uint256 |
U128 | uint128 |
U64 | uint64 |
u64 | uint64 |
u32 | uint32 |
u16 | uint16 |
u8 | uint8 |
bool | bool |
Bytes | bytes |
String | string |
Address | address |
B256 | bytes32 |
LyquidID | address |
RequiredLyquid | address |
NodeID | bytes32 |
Vec<T> where T: EthAbiType | dynamic array |
[T; N] where T: EthAbiType | fixed array |
Method inputs are supported for tuples up to 16 parameters. Return values support (), a single
ABI type, or tuples up to 16 values.
ABI Encoding Helpers
Use the ETH ABI helpers when building or decoding call data inside Lyquid code:
let input = encode_eth_call_params!(Address::ZERO, U256::from(1));
let decoded = decode_eth_call_params!(&input, to: Address, amount: U256);
For Lyquor-native field encoding, use encode_by_fields!, decode_by_fields!, encode_object,
and decode_object from the prelude.
Hosted Sites
A Lyquid can ship a static frontend in its assets/ directory (see
Packaging). A hosting node serves it under a per-Lyquid virtual host whose
first two DNS labels are the Lyquid ID and the node's DNS label:
<lyquid_id>.<node_id>[.<suffix>]
Under that host the node reserves a few control paths and serves everything else from the packaged asset bundle:
| Path | Serves |
|---|---|
/lyquid/statusz | JSON status: lyquid_id, image_digest, sequence_backend, backend_contract, lyquid_number |
/lyquid/api | Per-Lyquid JSON-RPC endpoint |
/lyquid/ws | Per-Lyquid WebSocket endpoint |
other /lyquid/... | reserved (returns 404) |
| any other path | static asset from the packaged assets/ bundle (e.g. /index.html) |
When debugging a hosted site, hit /lyquid/statusz or /lyquid/api first to confirm routing is
alive before suspecting asset packaging — see Testing and Debugging.
Current Interface Boundary
eth is currently the only export kind, so it is the only way to expose a Lyquid method as an
externally callable contract method. Static hosted assets and the /lyquid/... node routes (above)
are a separate mechanism from method export metadata.