Try the Call Decryption Oracle (Polygon or Ethereum) in Remix
What is Remix? Remix is a free, browser‑based IDE for Solidity smart contracts. You can write, compile, deploy, and call contracts directly in your browser and sign transactions with MetaMask (or another injected wallet). It’s ideal for quick trials—no local toolchain needed.
⚠️ Before you continue: Please read the Disclaimer.
By using this site, software, or contracts, you acknowledge that you have read and accepted it.
What you’ll do
- Construct encrypted hashed arguments, i.e.
- a byte sequence (
encArg) representing the encryption of an encoding of function arguments (ArgsDescriptor) - a byte sequence (
argHash) representing a hash of the function arguments.
- a byte sequence (
- Construct a call descriptor, i.e., the encoding of the target contract, method and signature.
- Use a test contract to go step by step and observe the five phases:
- Step 1: store the encrypted arguments in a smart contract used for testing (phase 1).
- Step 2: trigger the decryption of the arguments (phase 2) and following the callback with decripted arguments.
- The decryption oracle will perform the decryption and call a callback function on the test contract (phase 3).
- Step 3: trigger the routing of the decrypted encoded arguments to a function with typed arguments (phase 4).
- The test contract will receive the typed arguments in a function and store it (phase 5).
- Observes the stored data (encrypted arguments, hash commit, decrypted arguments, typed arguments) in the different phases.
Note: To keep the example simple the test contract serves as origin of the request to the decryption oracle and as the callback that receives the result.
Prerequisites
- MetaMask (or a compatible wallet) in your browser.
- Wallet connected to one of the supported chains with a little POL or ETH for gas.
Remark: If you do not have this already: add the MetaMask Plugin to Firefox and fund some POL or ETH to it. Ensure that you switched to the desired network.
Required Installations
You need Foundry (for cast) and Java 21 or later. Build the CLI JAR using the deployment guide.
For installation instructions see the setup page.
Apart from this we assume that openssl, cat, tr, xxd and sed are present.
The following commands should be run in a shell (macOS Terminal, Windows GitBash). You may use the copy button and just paste them into the shell.
Demo/Router Contract
You may either re-deploy our router/demo contract, or use the router created by the network deployment guide.
Deployment of the Router/Demo Contract
Use CALL_ROUTER_CONTRACT from the generated address file for your network:
Ethereum Mainnet: deployment/generated/ethereum/calls/contracts.env
Polygon Mainnet: deployment/generated/polygon/calls/contracts.env
Sepolia (Ethereum Testnet): deployment/generated/sepolia/calls/contracts.env
Amoy (Polygon Testnet): deployment/generated/amoy/calls/contracts.env
The corresponding off-chain call oracle must be running before requesting decryption.
Step‑by‑step in Remix
Preparation a): Open Remix
Open re-mix via the follwing URL
👈 *If you click the badge, Remix will open, load the interface definition of the router/demo contract ICallDecryptionOracleRouterDemo.sol and compile it.
Preparation b): Connect your wallet and select the router/demo contract.
- Connect your wallet (Environment -> Browser extension -> Injected Provider) (with the correct network).
- Fill in the address of the router (
CALL_ROUTER_CONTRACTfrom your network deployment) in At Address and click on At Address. - Checkout the functions under Deployed Contracts.
0) Generate encrypted hashed arguments
For a step-by-step introduction on how to generate the required componens, i.e.,
see the usage page. Here we have all steps a bit more condensed. Execute the following parts in a shell.
First, select the RPC and the Demo Contract addresses for the desired network. From the repository root, use the address files produced by the deployment guide:
Ethereum Mainnet
source deployment/generated/ethereum/calls/contracts.env
RPC_URL="https://ethereum-rpc.publicnode.com"
ORACLE_CONTRACT="$CALL_ORACLE_CONTRACT"
ROUTER_CONTRACT="$CALL_ROUTER_CONTRACT"
Polygon Mainnet
source deployment/generated/polygon/calls/contracts.env
RPC_URL="https://polygon-rpc.com"
ORACLE_CONTRACT="$CALL_ORACLE_CONTRACT"
ROUTER_CONTRACT="$CALL_ROUTER_CONTRACT"
Sepolia (Ethereum Testnet)
source deployment/generated/sepolia/calls/contracts.env
RPC_URL="https://ethereum-sepolia-rpc.publicnode.com"
ORACLE_CONTRACT="$CALL_ORACLE_CONTRACT"
ROUTER_CONTRACT="$CALL_ROUTER_CONTRACT"
Amoy (Polygon Testnet)
source deployment/generated/amoy/calls/contracts.env
RPC_URL="https://rpc-amoy.polygon.technology"
ORACLE_CONTRACT="$CALL_ORACLE_CONTRACT"
ROUTER_CONTRACT="$CALL_ROUTER_CONTRACT"
You can replace the public RPC endpoint with your own. Check that it matches the selected network:
test "$(cast chain-id --rpc-url "$RPC_URL")" = "$EXPECTED_CHAIN_ID"
Pasting the follwing lines in your shell (e.g. bash) will generate the encrypted arguments for (uint256) 20, (string) “Peach” (uint256) 990. It will construct a call descriptor for a function that has that signature.
ARGS_PLAIN=$(cast abi-encode "func(uint256,string,uint256)" 20 "Peach" 990)
ARGS_HASH=$(cast keccak "$ARGS_PLAIN")
export ARGS_DESCRIPTOR=$(cast abi-encode "wrap(address[],bytes)" [] $ARGS_PLAIN)
export ORACLE_PUBLIC_KEY=$(cast call "$ORACLE_CONTRACT" "getPublicKey()(bytes,bytes32)" --rpc-url "$RPC_URL" | head -n 1)
ENCRYPTED_ARGS=$(java -jar oracle-base/target/finmath-decryption-oracle-base-4.0.2-SNAPSHOT-cli.jar)
FEE_CALL_DECRYPT=$(cast call "$ORACLE_CONTRACT" "feeCall()(uint256)" --rpc-url "$RPC_URL" | awk '{print $1}')
echo "$FEE_CALL_DECRYPT"
DEMO_TARGET_CONTRACT=$ROUTER_CONTRACT
DEMO_TARGET_METHOD="demoTargetFunction"
DEMO_TARGET_VALID_UNTIL_BLOCK=0
DEMO_SELECTOR=$(cast sig "$DEMO_TARGET_METHOD(uint256,string,uint256)")
DEMO_CALL_DESCRIPTOR=$(cast abi-encode "CallDescriptor(address,bytes4,uint256)" $DEMO_TARGET_CONTRACT $DEMO_SELECTOR $DEMO_TARGET_VALID_UNTIL_BLOCK)
printf "\n\n\e[1mDemo Call Descriptor:\e[0m\n$DEMO_CALL_DESCRIPTOR\n\n\e[1mDemo Encrypted Arguments:\e[0m\n$ENCRYPTED_ARGS\n\n\e[1mArgs Hash:\e[0m\n$ARGS_HASH\n\n\e[1mFee (for Decrypt) in Wei (1E18):\e[0m\n$FEE_CALL_DECRYPT\n\n"
1) Store the encrypted hashed arguments in the demo contract
- Expand the arguments under the store method.
- Enter an unused
clientId,DEMO_CALL_DESCRIPTORascallDescriptorPlain,ENCRYPTED_ARGSasargsEncrypted, andARGS_HASHasargsHashin store and hit transact. - Once the transaction is completed, enter your chosen
clientIdingetResultand hit call.
👉 This will show you updated values of (phase, caller, targetContract, argsEncrypted, argsHash).
2) Trigger the execution with decrypted arguments
- Enter your chosen
clientIdin decrypt and hit transact. - Once the transaction is completed, enter your chosen
clientIdingetResultand hit call
👉 This will show you updated values of (phase, requestId).
⚠️ IMPORTANT: The function decrypt is payable. It may be required that you send a small fee to cover the cost of the call back. If a fee is required it is reported in the above definition of
$FEE_CALL_DECRYPT. The fee is in Wei (so 1/1E18 of an ETH or POL) and has to be put in thevalue-field.
Note: You should observe phase: 2 which indicates that the contract requested decryption of the arguments.
Once the decrypted arguments were deliverd to the callback you should observe phase: 3, however, sometimes
it takes a while until remix reflects this - you can move to the next step.
If the callback is reflected you will see updated values of (phase, argsPlain, argsHashComputed).
3) Trigger the routing of the decrypted arguments to a buisiness logic function (typed arguments)
-
Enter your chosen
clientIdin execute and hit transact. -
Once the transaction is completed, enter your chosen
clientIdingetResultand hit call
👉 This will show you updated values of (routingSuccess).
- Enter your chosen
clientIdingetDemoTargetValuesand hit call
👉 This will show you updated values of (arg1, arg2, arg3).
Common pitfalls
- Wrong network: ensure correct wallet: Ethereum (1) mainnet or Polygon (137) mainnet, Sepolia (11155111), or Amoy (80002).
- Incorrect value: Send exactly
feeCall()in wei for decrypt. Reset Remix Value to zero before store or execute. - Hex vs string: Data is bytes hex (starts with
0x), not a UTF‑8 string.
Safety tips
- Start with tiny test values and a throwaway account.
- Never paste secrets in Remix or comments.
- Verify contract addresses on an explorer before interacting.
Last updated: 2026-11-22
The paths above use the separate oracle/demo workflow. With the optional combined
workflow, omit the calls/ directory from each address-file path.
