@dippixyz/sdk v1.0.5
Dippi SDK for JS
This is the Dippi SDK for JavaScript, providing a wrapper around the Dippi API.
Installation
npm i @dippixyz/sdkUsage
Go to client.dippi.xyz to sign up and obtain an appToken and appId.
Dippi Client
To use the Dippi Client, follow the steps below:
Initialization:
const { Dippi, TBA } = require('@dippixyz/sdk'); const dippiClient = new Dippi({ appToken: [appToken], appId: [appId], url: 'https://api.dippi.xyz', });Authentication:
const { accessToken } = await dippiClient.auth.login(); dippiClient.setAuthToken(accessToken);Fetching User Profile:
const userProfile = await dippiClient.user.getProfile(userId);Working with Wallets, Applications, and Application Tokens:
const userWallets = await dippiClient.wallet.list(); const userApplications = await dippiClient.application.list(); const userApplicationToken = await dippiClient.applicationToken.retrieve(applicationId);
Token Bound Account (TBA)
To utilize the Token Bound Account (TBA) Class:
Initialization:
const tbaConfig = { appToken: [appToken], appId: [appId], url: 'https://api.dippi.xyz', auth: dippiClient.auth // Passing the auth instance from Dippi client }; const tba = new TBA(tbaConfig);Initialization and Creation for TBA:
const initArgs = { destinationWallet: 'destinationWalletAddress', nftContract: 'nftContractAddress', nftId: 'nftId' }; await tba.init(initArgs); await tba.create();
Example Application
Below is an example of how you can utilize the Dippi SDK and the TBA feature in a simple Node.js application.
const { Dippi, TBA } = require('@dippixyz/sdk');
// Initialize Dippi Client
const dippiClient = new Dippi({
appToken: 'yourAppToken',
appId: 'yourAppId',
url: 'https://api.dippi.xyz',
});
(async () => {
// Authenticate
const { accessToken } = await dippiClient.auth.login();
dippiClient.setAuthToken(accessToken);
// Fetch User Profile
const userId = 'yourUserId';
const userProfile = await dippiClient.user.getProfile(userId);
// List User Wallets
const userWallets = await dippiClient.wallet.list();
// List User Applications
const userApplications = await dippiClient.application.list();
// Retrieve User Application Token
const tokenId = 'yourTokenId';
const userApplicationToken = await dippiClient.applicationToken.retrieve(tokenId);
// Initialize TBA
const tbaConfig = {
appToken: 'yourAppToken',
appId: 'yourAppId',
url: 'https://api.dippi.xyz',
auth: dippiClient.auth,
_tokenBoundAccount: {}
};
const tba = new TBA(tbaConfig);
// Initialize and Create TBA
const initArgs = {
destinationWallet: 'destinationWalletAddress',
nftContract: 'nftContractAddress',
nftId: 'nftId'
};
await tba.init(initArgs);
await tba.create();
console.log('TBA created successfully!');
})();Make sure to replace the placeholders in the code with your actual data. Save this code in a file, say app.js, and run it using node app.js.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Acknowledgments
- Hat tip to anyone whose code was used
- Inspiration
- etc