ThetaDrop Connect
OAuth 2.0 Apps
Only ThetaDrop creators can make apps on ThetaDrop. Please contact your project manager for access.
Example Project
OAuth2.0 Login
Getting started
ThetaDropConnect - slim library to interact with the ThetaDrop accounts .
Installing ThetaDropConnect
Dapps must use the ThetaDropConnect library to interact (read-only) with the user's accounts on ThetaDrop to prove ownership of NFTs.
npm install --save @thetalabs/theta-drop-connect
Importing
Three different ways to import depending on your project.
node.js require
const ThetaDropConnect = require("@thetalabs/theta-drop-connect");
ES6
import {ThetaDropConnect} from '@thetalabs/theta-drop-connect';
JS Script Tag
<script type="application/javascript" src="//unpkg.com/@thetalabs/theta-drop-connect@latest/dist/theta-drop-connect.umd.js"></script>
<!-- Using the UMD version requires a bit of extra setup because of the setup of the ThetaDropConnect module (i.e. exporting ThetaDropConnect class)-->
<script type="application/javascript">
const ThetaDropConnect = window.ThetaDropConnect.ThetaDropConnect;
</script>
Initialize a ThetaDropConnect object
const thetaDrop = new ThetaDropConnect();
Login with ThetaDrop
Users must login to ThetaDrop to fetch their OAuth2.0 credentials.
Via Popup
const AppId = 'YOUR_THETA_APP_ID';
const RedirectUrl = 'YOUR_THETA_APP_REDIRECT_URL';
const result = await thetaDrop.connectViaPopup(AppId, RedirectUrl);
const {snsId, oauth2Token} = result;
Via Redirect
const AppId = 'YOUR_THETA_APP_ID';
const RedirectUrl = 'YOUR_THETA_APP_REDIRECT_URL';
thetaDrop.connectViaRedirect(AppId, RedirectUrl);
Fetch User
Fetch the account info for a connected user.
const userData = await thetaDrop.fetchUser();
Check User Ownership
Fetch the account info for a connected user.
Example proving ownership ThetaZilla NFT
const ThetaZillaId = 'type_2s2kcznsu3e06en43r3kg50b90c';
const filters = {
content_id: ThetaZillaId
};
const isOwner = await thetaDrop.checkUserIsOwner(filters);
Example proving ownership by any NFT created by ThetaZilla NFT
const ThetaZillaCreatorId = 'user_446i201m6304j1ts23d48cwuyxq';
const filters = {
content_creator_id: ThetaZillaCreatorId
};
const isOwner = await thetaDrop.checkUserIsOwner(filters);
Fetch NFTs
Example fetching all NFTs created by ThetaZilla NFT
const ThetaZillaCreatorId = 'user_446i201m6304j1ts23d48cwuyxq';
const filters = {
content_creator_id: ThetaZillaCreatorId
};
const response = thetaDrop.fetchUserNFTs();
Updated over 3 years ago