⚗️ Interact with the Lyquid (ETH API)
You should be able to invoke Lyquid's methods through a standard Ethereum API provided by Lyquor node. The contract address used in Ethereum API is the one you got in deployement.
Here is an example to try all the functions, using cast from Foundry.
Note: Functions returning
()(unit type) likeLyquidResult<()>cannot be called via Ethereum API since()has no corresponding ABI type. Use ABI-compatible return types for Ethereum-callable functions.
#!/bin/bash
export FOUNDRY_ETH_RPC_URL="http://localhost:10087/api" # --rpc-url equivalent
export KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
# 1. We first send an on-chain event to invoke greet()
cast send 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 "greet()" --private-key "$KEY" -q
sleep 1
# 2. Then check the state by get_greeting_message()
cast abi-decode "get_greeting_message() returns (string)" $(cast call 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 "get_greeting_message()")
# Output: "Hello, World! I've greeted 1 times to on-chain users"
# 3. Let's try to change the greeting text (network state)
cast send 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 "set_greeting(string)" "Nihao, Shijie!" --private-key "$KEY" -q
sleep 1
# 4. Then let's try the call with off-chain (instance) state:
cast abi-decode "greet_me() returns (string)" $(cast call 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 "greet_me()")
# Output: "Nihao, Shijie! I've greeted 1 times to on-chain users, and 1 times to you"
#
# 5. Do it again, you'll see the off-chain state is now changed.
cast abi-decode "greet_me() returns (string)" $(cast call 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 "greet_me()")
# Output: "Nihao, Shijie! I've greeted 1 times to on-chain users, and 2 times to you"