The Internet Computer by Dfinity Foundation promises to create "a limitless environment for smart contracts that run at web speed, serve web, scale, and reduce compute costs by a million times or more".
Ethereum apps that wants to deliver above and beyond of what is possible on chain often resorts to using regular centralised server solutions. Could off chain functionality instead run on the IC to create a mixed breed of Ethereum/IC apps - truly distributed, serverless and unstoppable?
The purpose with The Wall is to try out and showcase a few concepts with regards to building these crossover Ethereum/IC apps. A proof of concept, a demo and possibly a template to use as a starting point for more advanced apps.
- Authentication: Can public key cryptography already used by Ethereum be used to login to the IC?
- Link eth adresses to IC identities: If owners of eth adresses can easily prove ownership and link that verification with IC identities, that would open up many interesting app possibilites - voting, membership and other various DAO use cases.
The functionality of the app is super simple. Connect Metamask wallet, sign a login message, select a username. Then you can post messages to the wall.
Login details:
- User signs a login message using Metamask. The login includes a hashed secret that for the purpose of this demo is set by the app. To add an extra layer of security this secret (password) coud instead be chosen by the user.
- App generates the
Ed25519KeyIdentity
needed to authenticate with IC based on the signature hash. - Message hash and signature is sent to IC where the eth address used to sign the message is recovered and linked to the IC identity.
That's it! Now, the app can interact securely with IC, and IC has verified knowledge of which eth address the user controls.
Make sure you have the following installed:
node
npm
git
Download and install the DFINITY Canister SDK package by running the following command:
DFX_VERSION=0.7.0-beta.8 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
The app backend is written in Rust. The commands below install Rust, the package manager Cargo, etc.
curl https://sh.rustup.rs -sSf | sh
rustup update
rustup target add wasm32-unknown-unknown
sudo apt-get -y install cmake
cargo install ic-cdk-optimizer --root target
export PATH="./target/bin:$PATH"
git clone https://github.com/kristoferlund/ic-wall.git
npm install
Start Internet Computer
dfx start
Alt 1. Development mode with hot reload
- Deploy backend canisters
- Run next.js frontend in dev mode
dfx deploy wall
dfx deploy profile
npm run dev
Access on http://localhost:3000
Alt 2. Production mode
- Export static production version of next.js frontend
- Deploy all canisters
dfx deploy wall
dfx deploy profile
npm run export
dfx deploy ui
Access on http://localhost:8000
In case you receive "Could not find Canister ID from Request":
- Get UI canister ID
dfx canister id ui
Access on http://localhost:8000/?canisterId={id received in previous step}
Kristofer Lund, [email protected]
Telegram: @kristoferkristofer
Yes, please! Raise an issue or post a pull request.
[ ] Error handling all over!
[ ] Refactor canisters - better structure, naming etc.
MIT