decentralizedsurvey/survey
Deployment Steps
There are two major steps one has to follow in order to adapt and deploy our proposed solution:
- Deploy the underlying smart contract
IPFSHashStorage. - Adjust and deploy the Python code on HuggingFace.
1) Deploy IPFSHashStorage to Ethereum with Remix
This guide walks you through deploying the following Solidity contract to Ethereum (or a test network) using [Remix](https://remix.ethereum.org) and [MetaMask](https://metamask.io/). It also shows how to emit and view the Store event with an IPFS hash.
pragma solidity 0.8.18;
contract IPFSHashStorage {
event Store(string data);
function storeHash(string memory _IPFSHash) public {
emit Store(_IPFSHash);
}
}Prerequisites
- A modern browser (Chrome/Brave/Firefox recommended).
- The [MetaMask](https://metamask.io/) wallet installed and set up.
- Some ETH on the network you’ll deploy to:
- For a testnet (recommended): Use Sepolia testnet with test Sepolia ETH in MetaMask.
- For mainnet: You’ll need real ETH for gas fees.
1.1) Open Remix and create a Solidity file
- Go to [https://remix.ethereum.org](https://remix.ethereum.org).
- In the File Explorers panel (left sidebar), click File → New File.
- Name it
IPFSHashStorage.sol. - Paste the contract code from above into the file and save.
1.2) Compile the contract
- Click the Solidity compiler tab (the “compiler” icon) in the left sidebar.
- Set Compiler to 0.8.18 (matching the pragma).
- Click Compile And Run script.
1.3) Choose a deployment environment
Open the Deploy & run transactions tab (the “Ethereum” icon). Under Environment, pick Injected Provider - MetaMask, the follow these steps:
- In MetaMask, switch to your target network (e.g., Sepolia test network).
- Back in Remix, set Browser extension to Injected Provider - MetaMask.
- If a MetaMask pop-up asks you to connect, then approve it.
- Make sure ACCOUNT in Remix matches the address you want to use.
1.4) Deploy the contract
- In Contract, ensure
IPFSHashStorageis selected. - Click Deploy, and MetaMask will open.
- Confirm the transaction.
- Once mined, the contract will appear under Deployed Contracts with its address.
*You must copy the contract address (clipboard icon), as you will need to use that value inside the Python code in the following step*.
2) Adjust and deploy the Python code on HuggingFace
The easiest way of creating a new survey is to duplicate the Space at https://huggingface.co/spaces/decentralizedsurvey/survey into your own HuggingFace account and then customize the file `app.py`.
2.1) Duplicate the Space
- Open: https://huggingface.co/spaces/decentralizedsurvey/survey
- In the top-right of the Space page, click the ⋯ (three dots) menu → Duplicate this Space.
- In the dialog:
- Owner: pick your username or an organization you can write to.
- Space name: choose a new name (e.g.,
my-survey). - Visibility: Public or Private.
- Next, you have to provide four secrets that are not publicly visible, but these values are used by the survey code. Note that we use **Infura** as the API provider that facilitates our access to Ethereum and IPFS. Other providers can certainly be used, such as **Pinata**.
- infura: Infura's Ethereum endpoint
- password: Infura's username
- username: Infura's username
- pk: The private key of an Ethereum wallet, such as MetaMask. This will be used to sign and pay for the data stored on Ethereum
- Click Duplicate Space. After a few seconds, you’ll be redirected to your copy.
2.2) Confirm files and SDK
- Go to your duplicated Space.
- Open the Files tab; you should see (at least):
app.py— the Streamlit entry point.requirements.txt— Python dependencies.
2.3) Edit app.py in the browser
- In Files, click
app.py. - Click the Edit (pencil) button.
- Make your changes (see examples below).
- Enter a short commit message and click Commit changes.
Your Space will rebuild automatically and then transition to Running when ready.
Suggestion for customization:
- App title & page settings Look for
st.set_page_config(...)andst.title(...)at the top to change the browser title, page icon, and the on-page title.
- Smart contract address Make sure you change the address of the smart contract. The new value is what you obtained after finishing the previous major step.
- Questions & options The survey uses widgets like
st.radio,st.selectbox,st.text_input, etc. You can: - Change question text.
- Modify option lists (e.g., age ranges, yes/no, periods).
- Add validation (e.g., require an answer before proceeding).
- Multi-page flow The app tracks a
current_page(often viast.session_state). Pages are commonly implemented asif/elifsections by page number. To add a new page: - Duplicate a page block:
if st.session_state["current_page"] == 3:
st.header("New page")
# add widgets here
if st.button("Next"):
st.session_state["current_page"] += 1- Update any constants such as
total_number_pagesif used. - Ensure Back/Next buttons move between pages as expected.
- Media and styles
- Replace any
st.video("https://...")URL to change the intro video. - Use
st.markdown("<style>...</style>", unsafe_allow_html=True)for small CSS tweaks. - Add images via
st.image("path-or-url").
Next steps
Although the preceding steps target online surveys, the same architecture generalizes readily to other data-collection modalities. For example, with some adjustments to the Python front end, researchers can instrument semi-structured interviews or web-based behavioral experiments, capture rich response streams (audio, text, interaction logs), and serialize the results for content-addressable storage on IPFS, thereby preserving provenance and facilitating reproducible analysis across studies and domains.
