Appearance
Method Implementation
DB
Method Usage:
- For Example: login, read, getAddress, signTransaction
typescript
// Import necessary classes from the SDK
const {
SkcCms,
Popcode,
} = require('popcode-1155-sdk');
// Initialize SkcCms instance with base URL
const cms = new SkcCms(baseUrl);
// Define API key for authentication
const loginCreds = { apiKey: userConfig.apiKey };
// Log in using the provided credentials
await cms.login(loginCreds);
// Read EVM data from the CMS
const evmData = await cms.read('globals/evm', '');
// Set data retrieval offset
cms.withOffset(offset);
// Get the Ethereum address associated with the session
const address = await cms.getAddress();
// Sign any transaction data
const signedTxData = await cms.signTransaction(unsignedTxData);
Popcode
Static Method Usage:
- For Example: prepareDeployTxFromTracker
typescript
// Import necessary classes from the SDK
const {
SkcCms,
Popcode,
} = require('popcode-1155-sdk');
// Create an instance of the SkcCms(db) class, which connects to your base URL
const cms = new SkcCms(baseUrl);
// Create an instance of the Popcode class using the CMS instance and popcode ID
const popcodeI = new Popcode(cms, popcodeId);
// Prepare the transaction data for deployment using the `prepareDeployTxFromTracker` method through popcode instance
const unsignedTxData = await popcodeI.prepareDeployTxFromTracker(
cms, // CMS instance
popcodeFactoryContract // The factory contract for deployment
);
// Sign the transaction using the CMS instance
const signedTxData = await cms.signTransaction(unsignedTxData);
// Broadcast the signed transaction to the network
const broadcastResponse = await cms.provider.broadcastTransaction(signedTxData);
Instance Method Usage:
- For Example: getDetails
typescript
// Import necessary classes from the SDK
const {
SkcCms,
Popcode,
} = require('popcode-1155-sdk');
// Create an instance of the SkcCms(db) class, which connects to your base URL
const cms = new SkcCms(baseUrl);
// Create an instance of the Popcode class using the CMS instance and popcode ID
const popcodeI = new Popcode(cms, popcodeId);
// Connect the Popcode contract to the Popcode instance
await popcodeI.connectContract(cms);
// Connect to an ARS gateway if needed for additional interactions
await popcodeI.connectArsGateway(cms);
// Call the `getAllDetails` method through Popcode Instance
const popcodeDetails = await popcodeI.getAllDetails();
DLPC
Static Method Usage:
- For example, prepareDeployTxFromTracker
typescript
// Import necessary classes from the SDK
const {
SkcCms,
Dlpc
} = require('popcode-1155-sdk');
// Initialize the CMS instance with the base URL
const cms = new SkcCms(baseUrl);
// Create an instance of the Dlpc class using the CMS instance and Dlpc ID
// The CMS class implements the necessary database functions
const dlpcI = new Dlpc(cms, dlpcId);
// Prepare the transaction data for deployment using the `prepareDeployTxFromTracker` method through dlpc instance
const unsignedTxData = await dlpcI.prepareDeployTxFromTracker(
cms, // CMS instance
dlpcFactoryContract // The factory contract for deployment
);
// Sign the transaction using CMS signer capabilities
const signedTxData = await cms.signTransaction(unsignedTxData);
// Broadcast the signed transaction through the CMS provider
const broadcastResponse = await cms.provider.broadcastTransaction(signedTxData);
Instance Method Usage:
Connecting to CMS and ARS
- For example, getDetails and register
typescript
// Import necessary classes from the SDK
const {
SkcCms,
Dlpc
} = require('popcode-1155-sdk');
// Initialize the CMS instance with the base URL
const cms = new SkcCms(baseUrl);
// Create an instance of the Dlpc class using the CMS instance and Dlpc ID
const dlpcI = new Dlpc(cms, dlpcId);
// Connect to the Dlpc contract
await dlpcI.connectContract(cms);
// Fetch details from the Dlpc contract
const dlpcDetails = await dlpcI.getAllDetails();
// Connect to the ARS Gateway
await dlpcI.connectArsGateway(cms);
// Register an asset with the ARS Gateway
const registerResponse = await dlpcI.register(assetId, dId, salt);
Skucode
Static and Instance Method Usage:
- For example, createNew and prepareDeployTxFromTracker
typescript
// Import necessary classes from the SDK
const {
SkcCms,
Skucode
} = require('popcode-1155-sdk');
// Initialize the CMS instance with the base URL
const cms = new SkcCms(baseUrl);
// Create an instance of the Skucode class using the static createNew method
const skucodeI = await Skucode.createNew(cms, skucodeOptions);
// Prepare the transaction data for deployment using the `prepareDeployTxFromTracker` method through skucode instance
const unsignedTxData = skucodeI.prepareDeployTxFromTracker(
cms, // CMS instance
);
// Sign the transaction using CMS signer capabilities
const signedTxData = await cms.signTransaction(unsignedTxData);
// Broadcast the signed transaction through the CMS provider
const broadcastResponse = await cms.provider.broadcastTransaction(signedTxData);
SkcCMSVault
Method Usage:
- For example, getAddress
typescript
// Import necessary classes from the SDK
const {
SkcCms,
kmsUtils
} = require('popcode-1155-sdk');
// Initialize SkcCms with the base URL
const cms = new SkcCms(baseUrl);
// Authenticate and connect to the CMS
await skcCmsInstance.connect({
email: email,
password: password,
});
// Initialize the SkcCmsVault instance with CMS, offset, and provider
const skcVaultInstance = new kmsUtils.SkcCmsVault(
skcCmsInstance, // Connected CMS instance
offset, // Offset for key derivation
provider // Blockchain provider
);
// Get the address associated with the vault instance
await skcVaultInstance.getAddress();
SkcVault
Method Usage:
- For example, storeMnemonic
typescript
// Import necessary classes from the SDK
const {
SkcCms,
kmsUtils
} = require('popcode-1155-sdk');
// Define options for the VaultClient
const VaultClientOptions = {
pluginPath: pluginPath, // Path to the plugin used by the vault
vaultAddress: vaultAddress, // Address of the vault
vaultToken: vaultToken, // Token for authenticating with the vault
};
// Initialize a LocalVault instance with VaultClientOptions and offset
const skcVaultInstance = new kmsUtils.LocalVault(
VaultClientOptions, // Options needed for initializing the vault client
offset // Offset for key derivation
);
// Connect to the blockchain provider
await skcVaultInstance.connect(Provider);
// Store the mnemonic securely in the vault
await skcVaultInstance.storeMnemonic(mnemonic);