Skip to main content

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 typeETH ABI type
U256uint256
U128uint128
U64uint64
u64uint64
u32uint32
u16uint16
u8uint8
boolbool
Bytesbytes
Stringstring
Addressaddress
B256bytes32
LyquidIDaddress
RequiredLyquidaddress
NodeIDbytes32
Vec<T> where T: EthAbiTypedynamic array
[T; N] where T: EthAbiTypefixed 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:

PathServes
/lyquid/statuszJSON status: lyquid_id, image_digest, sequence_backend, backend_contract, lyquid_number
/lyquid/apiPer-Lyquid JSON-RPC endpoint
/lyquid/wsPer-Lyquid WebSocket endpoint
other /lyquid/...reserved (returns 404)
any other pathstatic 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.