acgodson / snapmemo-node

Node Server for handling Social Share requests from snapmemo client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

welcome

Snapmemo allows users to save, share and keep track of memorable photos as digital assets on blockchain

See frontend repo

This is a serverside implementation that handles tweeting of new NFT photos from authorized creators as soon as they are published on web3.storage and algorand blockchain.

One click for everything

  • Store Photos and metadata - on ipfs decentralized storage system via web3.storage

  • Create digital Assets - of saved photos on blockchain

  • Tweet new NFT photos - automatically

Testing

To run server locally - Run npm install and npm run start:dev and you're ready to go!

Converting web3Storage CIDv1 to 32 bytes string to fit ASA standard (Algorand asset standard)

import CID from 'cids';


   function hexToBase64(hexStr) {
        let base64 = "";
        for (let i = 0; i < hexStr.length; i++) {
            base64 += !((i - 1) & 1)
                ? String.fromCharCode(parseInt(hexStr.substring(i - 1, i + 1), 16))
                : "";
        }
        return btoa(base64);

 const hex = new CID(cid).toString('base16').substring(9)

        let base64 = hexToBase64(hex);

        const buffer = Buffer.from(base64, "base64");
        const response = JSON.stringify({
            base64: base64,
            hex: hex,
            buffer: buffer.length
        });

Links

Contributors

@cgold54 @AC_godson

About

Node Server for handling Social Share requests from snapmemo client

License:MIT License


Languages

Language:JavaScript 100.0%