Giter Club home page Giter Club logo

link's Introduction

link! โ€’ The Unstoppable URL Shortener
[matrix] discord [built-with-ink]


This is an unstoppable URL shortener. It allows users to store a short version of a URL, this short (often mnemonic) version can be resolved back to the long version.

The section Why? below contains more details on the distinction to traditional URL shorteners.

We built this project to illustrate how a full-stack DApp can be built with:

  • Smart Contract: ink! as the programming language for the contract.
  • Blockchain: We use the Substrate blockchain framework with it's module for smart contracts (pallet-contracts). You can use Substrate to build either standalone blockchains or parachains for Polkadot and Kusama.
  • Frontend: For our MVP we use the polkadot-js API with hardcoded RPC and node URLs.

In our next iteration of this MVP we want to migrate the frontend to utilize substrate-connect under the hood. In consequence the frontend would be truly trustless, there would then be no need to put trust in a server that e.g. the RPC return values are indeed what is stored on the blockchain.

Rococo Deployment

The link! contract is deployed to Rococo at the following address:

5GdHQQkRHvEEE4sDkcLkxCCumSkw2SFBJSLKzbMTNARLTXz3

Its metadata can be found here. It is upgradeable by the chain's sudo account.

๐Ÿค” Why?

Popular URL shorteners are for-profit companies, relying on them to infinitely store a URL can only be done by trusting those third parties to always adhere to their pinky promise.

In the past there have been a number of incidents where URL shorteners removed the short URL at some point for a variety of reasons: commercial interests, moral values, legal obligations, โ€ฆ.

We're not aware of incidents where URL shortener services maliciously decided to change the resolved URL after the fact, but it's something that can in principle be done. Importantly this could also be done without the companies intention. An attacker could modify the company database and there would be no way for a user to know that the short URL now resolves to something else.

Point being: you don't have any guarantee that the short URL will always be resolved to the same long URL. You have to trust the central service.

Blockchains allow us to build decentralized applications in a trustless manner. A central ledger ensures that you can't simply edit a value, the nodes in a blockchain network (often many thousands) have to come to consensus on this change. You don't have to trust a central entity anymore that it will always adhere to its promises. Instead you can put your trust in the underlying scientific mechanisms behind the blockchain network.

With this project we illustrate how our stack can be used to build a decentralized URL shortener where you don't have to put trust in a singular entity.

Deploy

In contracts folder

pnpm run script deploy

link's People

Contributors

achimcc avatar alvicsam avatar athei avatar cmichi avatar dependabot[bot] avatar doubleotheven avatar erler avatar goldsteinsveta avatar peetzweg avatar smiasojed avatar statictype avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

link's Issues

False error message shown

To reproduce:

  1. Paste an URL
  2. Delete letters from the alias field so that the error is shown
  3. Type more letters in the alias field
  4. See incorrect error for a brief second
Screen.Recording.2023-06-01.at.19.14.24.mov

Cannot connect if no accounts are present

The wallet connection flow goes doesn't handle the possibility of the user not having set up an account yet. Clicking on the "Connect to... " button doesn't do anything.
Noticed this on Firefox, where there are no imported accounts in the pjs extension. Not sure if it's browser specific.

Screen.Recording.2023-06-07.at.18.22.21.mov

Handle non-existing slugs

When a user tries to go to tiny.ink/some-non-existing-slug the app doesn't do anything.
This is an older issue, unrelated to useInk migration

Integrated Rococo faucet

Would be nice to allow people to drip funds in their account directly from the app. Needs design.

Add basic contract

  • Add resolve function
  • Add shorten(slug: Vec<u8>, url: Vec<u8>) -> Result<()> function, assert that len >= 5.
  • Make it upgradeable with a multisig using a proxy account

Persist the selected account

Ideally, when you navigate around or refresh the page the same account should be selected in the dropdown. If the account doesn't exist anymore, it should default to the first account found.

Page immediately blanks after entering URL in textbox

I am using the live version here: https://tiny.ink/

I have Polkadot-JS extension installed, with valid accounts, and tried in both Brave and Chrome.

I have tried this both before and after connecting my wallet, but I see the same behavior.

TO REPRODUCE:

  1. Visit page
  2. Enter any URL in the textbox labeled "Paste an URL to get cost estimations" - for example, "https://en.wikipedia.org/wiki/Cockatiel". Alternatively, you can start typing and the same behavior will occur after a few keystrokes.

EXPECTED BEHAVIOR:

  1. User can then click "Shorten"

OBSERVED BEHAVIOR:

  1. Page becomes entirely blank (only purple background)

Waiting time too long

The waiting time for a shorten transaction to finalize is longer than 12s in the UI, meaning something is lagging somewhere
Also the resolving takes up to a few seconds sometimes and it used to be faster

Form is disabled after connecting wallet

If the user already pasted a URL in the field and connects the wallet via the button below, all inputs and submit button are disabled.

Note: doesn't happen if the user connects via the top right corner button or if the form is empty when clicking the button.

Screen.Recording.2023-06-05.at.11.01.52.mov

Allow users to revisit the links they create

A links overview page was introduced here #20 but i removed it from the MVP.
I think it might be cleaner to use react-router instead of HeadlessUI tabs, but the layout can be copy-pasted.
Maybe we should limit to displaying 15 links, the list can grow fast.

Is there a way to get all the links shortened by an account from contract storage?

Check if a signer extension is available

Currently we assume users have the Polkadot.js extension in their browser. Other wallets haven't been tested.
The user experience is very poor for first time users. There is no guide to install a compatible extension and create a new account.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.