Try the 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

  • Deploy a tiny DemoContract contract in Remix (on Polygon PoS mainnet or Ethereum mainnet).
  • Let the DemoContract send request to the live Decryption Oracle:
    • Generate an encrypted key + hash,
    • optionally verify the encrypted key against the hash,
    • and finally decrypt it—end‑to‑end.

Note: To keep the example simple (1 file), the DemoContract 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 Polygon PoS (aka “Polygon Mainnet”) or Ethereum Mainnet 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.


Step‑by‑step in Remix

Try it on Remix

👈 If you click the badge, Remix will open, load DemoContract.sol and compile it;
in that case you can skip step 1), 2) and 3) and directly start at 👉 step 4) below.

1) Open Remix and select the plugins

  1. Go to Remix: remix.ethereum.org.
  2. In the left sidebar, ensure Solidity Compiler and Deploy & Run Transactions are enabled.

2) Create the callback contract

  1. In the File Explorer, click New File → name it DemoContract.sol.
  2. Copy and Paste the code below and Save.
Error during retrieving content skip as ignoreDownloadError activated.

3) Compile

  • Open Solidity Compiler → set Compiler to 0.8.24 (or newer that supports 0.8.24 sources).
  • Click Compile DemoContract.sol and ensure no errors.


4) Connect wallet and select environment

  • Ensure your wallet is on the desired network, either Polygon Mainnet or Ethereum Mainnet or Polygon Test Amoy or Ethereum Test Sepolia.
  • Open Deploy & Run Transactions panel.
  • Set Environment to Injected Provider – MetaMask. Approve the connection if prompted.

5) Deploy DemoContract

  • (Still in Deploy & Run Transactions panel)
  • In Contract, choose DemoContract.
  • In Deploy & Verify add the Constructor arguments and paste the oracle address:
    • If you are on Polygon Mainnet: 0xB387746f1048645F142cAC13e762A3931f3114Ba
    • If you are on Ethereum Mainnet: 0xa116A2BDbef2BA379eD6eCED40504D4f28c755fc
    • If you are on Amoy - Polygon Testnet: 0x86A6A4707526e230B66FE6E15A321b16000C076f
    • If you are on Spolia - Ethereum Testnet: 0xda273EFE2F491903AB3DAf8Bee1A79A8F64e33E0
  • Click Deploy.
  • Confirm in MetaMask: Confirm the transaction in MetaMask.

Open the Demo Contract under Deployed Contracts. You may now use its methods.


6) Generate an encrypted key (no input needed)

  1. Call feeGenerate() and note the returned value (wei).
  2. Expand requestGenerateEncryptedHashedKey(...) and fill:
    • id: e.g., 101
    • transaction: 0x (or any correlation bytes)
  3. In the Value field (top-right of the panel), input the exact fee from feeGenerate() and set the unit to wei.
  4. Click transact.
  5. Confirm in MetaMask: Confirm the transaction in MetaMask.
  6. Read results:
    • In the deployed DemoContract instance call getResults with the id (e.g. 101).

👉 This will show you the encrypted key and the hash of the key - (encryptedKey, hashedKey, receiverContract, transaction).

Note on getResults: If the returned status is 1, the result is still pending. Just try again a few seconds later. In rare cases it can take longer (minutes).


7) Optional: Verify a previously generated key

  1. Call feeVerify() and note the value (wei).
  2. Expand requestVerifyEncryptedKey(...) and fill:
    • id: e.g., 102
    • encryptedKey: paste the hex from getResults of the “Generate” step.
  3. Set Value to the number obtained from feeVerify() (wei).
  4. Click transact.
  5. Confirm in MetaMask: Confirm the transaction in MetaMask.
  6. Read results:
    • In the deployed DemoContract instance call getResults with the id (e.g. 102).

👉 This will show you the contract that is eligible to receive the decryption (receiverContract) and the transaction (transaction) that are associated with the key and the hash of the key (hashedKey), without exposing the decrypted key.


8) Decrypt a previously generated key

  1. Call feeDecrypt() and note the value (wei).
  2. Expand requestDecrypt(...) and fill:
    • id: e.g., 103
    • encryptedKey: paste the hex from getResults of the “Generate” step.
    • transaction: 0x
  3. Set Value to the number obtained from feeDecrypt() (wei).
  4. Click transact.
  5. Confirm in MetaMask: Confirm the transaction in MetaMask.
  6. Read results:
    • In the deployed DemoContract instance call getResults with the id (e.g. 103) (key).

👉 This will show you the decrypted key (key), for which its hash equals the hash returned by generate (hashedKey).


Common pitfalls

  • Wrong network: ensure correct wallet: Ethereum (1) mainnet or Polygon (137) mainnet or Amoy (80002).
  • No value sent: You must send value = feeGenerate() or value = feeDecrypt() (units: wei).
  • Hex vs string: encryptedKey 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