eosio-dapp-router

Generates a static page (to be hosted on IPFS) for redirecting to a dapp URL registered in the eosio contract metadata.

The script iterates over given endpoints (passed in the URL as an IPFS address) and compares the results, so there is no need to trust a specific eos node.

example redirect to here

Example use cases

  • Bookmark which redirects to a static DAO chosen frontend (content can also be hosted in IPFS)
  • Contract developers can declare the recommended ui for the contract
  • Website discovery without DNS

Hashes

  • Mainnet endpoints hash: QmTfUGaVqXYgvzrAJpseZcNVyqKTitd7NkNF9XG19aAza2

  • Kylin endpoints hash: QmZEMyJANVnjSDB6ujQLMbNQ56U65SG8nzx78wQ2SnouS1

  • Main page hash: Qma9Wvk8gnqmhDkNGNQiQNib2QH12LkdCeo9nJAtS59J52

Project setup

yarn install

Set Default App

TBD

Set Default Endpoints

TBD

Init local IPFS

npm run initipfs

Deploy

npm run deploy

open browser at http://localhost:9090/ipfs/QmUuduj7gQozD57sjo1JmwbQifqpGxtGbQgRFSH1T41YoV#?endpoints=QmYzeayjNXdPxosFEYFDphMGwEzBX7s3vzK6sVaaECVxUB&name=yourapp

or https://cloudflare-ipfs.com/ipfs/QmUuduj7gQozD57sjo1JmwbQifqpGxtGbQgRFSH1T41YoV/#?endpoints=QmYzeayjNXdPxosFEYFDphMGwEzBX7s3vzK6sVaaECVxUB&name=yourapp

Redeploy endpoint list

npx --no-install jsipfs add .\endpoints-kylin.list
npx --no-install jsipfs add .\endpoints-mainnet.list

Contract Setup

Contract support for metadata

Add the following code to your contract's class body:

    TABLE meta { 
        name key; 
        std::string value; 
        uint64_t primary_key() const { return key.value; } 
    }; 
    typedef eosio::multi_index<"meta"_n, meta> _t_meta; 
    [[eosio::action]] 
    void setmeta(
        name key, 
        std::string value 
    ){ 
        require_auth(_self); 
        _t_meta items( _self, _self.value ); 
        auto existing = items.find( key.value ); 
        if(existing == items.end()) { 
            items.emplace(_self, [&]( auto& a ){ 
                a.key = key; 
                a.value = value; 
            }); 
        } else { 
            items.modify( *existing, eosio::same_payer, [&]( auto& a ) { 
                a.value = value; 
            }); 
        } 
    }       

Call setmeta

cleos push action yourcontract setmeta "[\"frontend.url\", \"https://mywebsite.com\"]" -p yourcontract@active
  • Frontend URL "frontend.url"

  • Frontend code git "frontend.git"

  • Contract code git "contract.git"