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 the chain tooling) and jbang (to start a web service with the renderer).
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 an existing deployment under one of the flowing addresses:
Deployment of the Router/Demo Contract
Ethereum Mainnet
0xcA7E032a351D654c00A8262BCb1Fe01c8c351203
Polygon Mainnet
0x07f873654A0C7aDfe2F2DBA0d5d453DEf263dB60
Sepolia (Ethereum Testnet)
0xdd3292f3743002CA4e2F637C09D4b6C11F1fA094
Amoy (Polygon Testnet)
0xBEFA3d598cC127b8Bc7b9E2dCDc29349d68a39A4
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 conteract.
- Connect your wallet (Environment -> Browser extension -> Injected Provider) (with the correct network).
- Fill in the address of the router ($ROUTER above, depending on the network) 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. Set
Ethereum Mainnet
RPC_URL="https://ethereum-rpc.publicnode.com"
ORACLE_CONTRACT=0x13E6464A85a63c9214a4F04cd942466F35D17E54
ROUTER_CONTRACT=0xcA7E032a351D654c00A8262BCb1Fe01c8c351203
Polygon Mainnet
RPC_URL="https://polygon-rpc.com"
ORACLE_CONTRACT=0x22a687a3a0F958AccC1395C4D134F297eaCa1B2B
ROUTER_CONTRACT=0x07f873654A0C7aDfe2F2DBA0d5d453DEf263dB60
Sepolia (Ethereum Testnet)
RPC_URL="https://ethereum-sepolia-rpc.publicnode.com"
ORACLE_CONTRACT=0x668a5e0eE0dD80F08AE7cf7D91Af84d6bB28f70D
ROUTER_CONTRACT=0xdd3292f3743002CA4e2F637C09D4b6C11F1fA094
Amoy (Polygon Testnet)
RPC_URL="https://rpc-amoy.polygon.technology"
ORACLE_CONTRACT=0x27aF9135aF9a7FEe7f9dde4d595E200B0c602576
ROUTER_CONTRACT=0xBEFA3d598cC127b8Bc7b9E2dCDc29349d68a39A4
Pasting the follwing lines in your shell (e.g. bash) will generate the ecrypted 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=$(jbang net.finmath:finmath-decryption-oracle-base:2.5.5:cli)
FEE_CALL_DECRYPT=$(cast call "$ORACLE_CONTRACT" "feeCall()(uint256)" --rpc-url "$RPC_URL")
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 a chosen
clientId, the encrypted arguments (encArgs) and the hash (argsHash) in store and hit transact. - Once the transaction is completed, enter your chosen
clientIdingetResultsand 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
clientIdingetResultsand 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
clientIdingetResultsand hit call
👉 This will show you updated values of (routingSuccess).
- Enter your chosen
clientIdingetResultsDemoand 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 or Amoy (80002).
- No value sent: You must send
value = feeCall()(units: wei). - 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: 2025‑11‑09
