Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NFT list to wallet #4

Open
ghost opened this issue Feb 22, 2022 · 1 comment
Open

Add NFT list to wallet #4

ghost opened this issue Feb 22, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 22, 2022

post to get the list of banano NFTs an address owns.

example address ban_1jsdpfa46qh5u49t3mbhisngtqunj43zc1k9x73okk6syi54zkugy1psyer1

https://nft.coranos.cc/api?action=get_nft_owner_assets&owner=ban_1jsdpfa46qh5u49t3mbhisngtqunj43zc1k9x73okk6syi54zkugy1psyer1

response (no nfts):

{"success":true,"asset_owners":[]}

response (some nfts)

    {
    "success":true,
    "asset_owners": [
        {
         "template":"QmbEFhEg7h4fuS34huLARat7KqSQutPfa55fjE8irBEq6G",
       }
     ]
    }

then get:

https://gateway.pinata.cloud/ipfs/${template}

response:

    {
        "title":"The Frogs and the Ox",
        "art_data_ipfs_cid":"QmPU4BG4Kxorz769xdrVTFxXSQxe6x6ofCyKoMxrNZfjxE"
    }

then get:

https://gateway.pinata.cloud/ipfs/${art_data_ipfs_cid}

and process it using the js:

        const imageUrl = ipfsApiUrl + '/' + imageIpfsCid;
        const imageResponse = await fetch(imageUrl, {
          method: 'GET',
          headers: {
            'content-type': 'image',
          },
        });
        const imageContentType = imageResponse.headers.get('content-type');

        if (imageResponse.status === 200) {
          const imageBlob = await imageResponse.blob();
          if (imageContentType == 'image/svg+xml') {
            const text = await imageBlob.text();
            // html += text;
            const svg = `data:image/svg+xml;base64,${btoa(text)}`;
            html += `<object title="${imageIpfsCid}" style="width:30vmin;height30vmin;" type="image/svg+xml" data="${svg}"></object>`;
          } else if (imageContentType == 'image/png' || imageContentType == 'image/gif' || imageContentType == 'image/png') {
            const imageObjectUrl = URL.createObjectURL(imageBlob);
            html += `<img title="${imageIpfsCid}" style="width:30vmin;height30vmin;" src="${imageObjectUrl}"></img>`;
          } else {
            html += `Unsupported Content Type: ${imageContentType}`;
          }
        } else {
          html = 'error:' + imageResponse.status + ' ' + imageResponse.statusText;
          allowReload = 'true';
        }
@stjet
Copy link
Contributor

stjet commented Jan 4, 2024

Banfts has an API for this too: https://api.banfts.com/api/v1/account/ban_1o7ija3mdbmpzt8qfnck583tn99fiupgbyzxtbk5h4g6j57a7rawge6yzxqp/assets
And an endpoint for the metadata: https://api.banfts.com/api/v1/assets/supply/526ADF062C5E9A93A56E1FAC890DD1CE7C61DC1970BDAEFA6054DD7B044A88B1

I'll have to double check the CORS stuff, but whitelisting bananostand shouldn't be a problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant