# llms-ctx.txt # INTRODUCTION sdk_name: skc-sct-sdk description: A modular SDK by Skuchain for inventory financing, control, and enterprise blockchain solutions. purpose: Extends ethers.Contract functionality, enabling cryptographic signing, digital asset management, and blockchain interactions. # FEATURES features: - Extends ethers.Contract for simplified event handling, transaction management, and event decoding. - Secure key management with integrated KMS. - Database interaction for seamless data storage and querying. - Advanced human-readable ABI interaction features. - Generates and manages BIP-39 mnemonic phrases and HD wallets. - Connects to Ethereum blockchain networks via JSON-RPC. - Written in TypeScript for type safety. # INSTALLATION node_version: v20.11.0 install_command: npm install # IMPORTS import_all: import * as sdk from "skc-sct-sdk"; import_specific: | import { SkcSctCms, Database, SkcPrivacyService, PrivacyServiceGateway, generateKeys, generateHdAddressIndex, generateSingleUseEthPubKey, Sct, TokenLedger } from "skc-sct-sdk"; # TERMINOLOGIES terminologies: - KMS: Manages cryptographic keys and signing operations securely. - ABI: Schema for interacting with Ethereum smart contracts. - Salt: Random data for enhancing encryption processes. - Vault: Secure storage for cryptographic assets. - Transaction Receipt: Logs and status of blockchain transactions. - Log Decoding: Converts blockchain logs to human-readable formats. # UTILITY FUNCTIONS utility_functions: - generateKeys(): Generates Ethereum and Cosmos key pairs. Returns mnemonic if no parameters provided. Parameters: - mnemonic (optional): string of 12 or 24 words - derivationPath (optional): Custom derivation path - generateHdAddressIndex(uuid: string): Maps UUID v4 to 32-bit integer for HD wallet derivation Parameters: - uuid: string - generateSingleUseEthPubKey(ethPublicKey: string, uuid: string): Generates single-use Ethereum public key Parameters: - ethereumPublicKey: string - uuid: string - prepareTxData( contract: ethers.Contract, method: string, args: any[], signerAddress: string, provider: ethers.Provider, memo?: string ): Prepares transaction data for a given smart contract method call Parameters: - `contract`: ethers.Contract - The smart contract to interact with - `method`: string - The method name to call - `args`: any[] - The arguments to pass to the method - `signerAddress`: string - The address of the signer - `provider`: ethers.Provider - The provider to interact with the Ethereum network - `memo` (Optional): string - The memo to attach to the transaction - prepareEthTransferTxData( fromAddress: string, toAddress: string, amountEther: string, provider: ethers.Provider ): Prepares transaction data for transferring Ether between addresses Parameters: - `fromAddress`: string - The address to send Ether from - `toAddress`: string - The address to send Ether to - `amountEther`: string - The amount of Ether to transfer - `provider`: ethers.Provider - The provider to interact with the Ethereum network - retrieveMemoFromTxHash( contract: ethers.Contract, txHash: string, provider: ethers.Provider ): Retrieves the memo (if present) from a transaction hash by decoding the transaction data Parameters: - `contract`: ethers.Contract - The smart contract to interact with - `txHash`: string - The transaction hash to decode - `provider`: ethers.Provider - The provider to interact with the Ethereum network - safeBigIntToNumber( value: bigint ): Safely converts a BigInt value to a number, ensuring it falls within the safe integer range Parameters: - `value`: bigint - The BigInt value to convert - trimNullCharacters( str: string ): Removes trailing null characters (\u0000) from a string Parameters: - `str`: string - The string to process - isValidDate( timestamp: any ): Validates if the provided Unix timestamp is a date that is today or in the future Parameters: - `timestamp`: any - The timestamp to validate - filterEventsByIdentity( events: any, identity: string ): Filters events by Identity Parameters: - `events`: any - The list of events to filter - `identity`: string - The identity to filter events by - ethereumAddressToDecimal( address: string ): Converts an Ethereum address to its decimal representation Parameters: - `address`: string - The Ethereum address to convert - decodeLogsFromReceipt( receipt: any ): Decodes logs from a transaction receipt Parameters: - `receipt`: any - The transaction receipt to decode - getEventsFromAbi( abi: any ): Retrieves events from an ABI definition Parameters: - `abi`: any - The ABI to extract events from - getEventStruct( events: any ): Extracts event structures from ABI events Parameters: - `events`: any - The events to extract structures from - replacer( key: any, value: any ): Replaces BigInt values with their string representation during JSON serialization Parameters: - `key`: any - The key to process - `value`: any - The value to process - fundAccount( faucetUrl: string, address: string ): Funds an account using a specified faucet URL Parameters: - `faucetUrl`: string - The URL of the faucet to use - `address`: string - The address to fund - generateRandomListingId(): Generates a random listing ID consisting of hexadecimal characters Parameters: None - generateOfferId( length?: number ): Generates a random offer ID of a specified length using hexadecimal characters Parameters: - `length` (Optional): number - The length of the generated offer ID - transformDatastore( dataStore: string ): Transforms a datastore name to its corresponding collection name Parameters: - `dataStore`: string - The datastore name to transform - passRefutationPeriod( provider: ethers.JsonRpcProvider ): Passes the refutation period by advancing the blockchain time Parameters: - `provider`: ethers.JsonRpcProvider - The provider to interact with the Ethereum network - getAccountBalance( address: string, provider: ethers.Provider ): Fetches the current balance at an address Parameters: - `address`: string - The address to fetch the balance for - `provider`: ethers.Provider - The provider to interact with the Ethereum network - isContract( address: string, provider: ethers.Provider ): Determines whether the given address is a contract or an externally owned account (EOA) Parameters: - `address`: string - The address to check - `provider`: ethers.Provider - The provider to interact with the Ethereum network - isZipFile( buffer: Buffer ): Checks if the given buffer is a zip file by inspecting its content Parameters: - `buffer`: Buffer - The buffer to inspect - verifySignature( signature: string, message: string | Uint8Array, expectedAddress: string ): Verifies if a given signature matches the expected address by recovering the signer from the message Parameters: - `signature`: string - The signature to verify - `message`: string | Uint8Array - The message or data that was signed - `expectedAddress`: string - The expected signer address # Interfaces interfaces: - Database: Provides CRUD operations on a database. methods: - create(collectionName: string, data: any): Promise - read(collectionName: string, query: string): Promise - update(collectionName: string, updateData: any, key: string): Promise - delete(collectionName: string, query: string): Promise - SkcCmsConnectOptions: Defines options for CMS connection. Parameters: - email?: string - password?: string - apiKey?: string - PrivacyServiceGateway: Handles interactions with the Privacy Service. methods: - register(assetId: string, dId: string, offset: string, assetType?: string, metadata?: object, refId?: string, signature?: string, accessUrl?: string): Promise - resolve(assetId: string, requestedAddress: string[], requesterPublicKey?: string, signature?: string): Promise - decrypt(cipherText: string): Promise - SkcPrivacyServiceConnectOptions: Defines connection options for the Privacy Service. Parameters: - email?: string - password?: string - apiKey?: string - IdPredictionOptions: Used for ID prediction configurations. Parameters: - admin: string - tokenName: string - tokenSymbol: string - initialSupply: string - offset: string - skucodeType: string - factoryAddress: string - TokenLedgerIdPredictionOptions: Used for predictions specific to token ledgers. Parameters: - uri: string - offset: string - factoryAddress: string - tokenLedgerType: string - SkucodeOptions: Represents options for SKU code configurations. Parameters: - denom: string - category: string - itemId: string - description?: string - tokenName: string - tokenSymbol: string - initialSupply: string - offset: string - skucodeType: 'Mintable' | 'Wrappable' - KeyPairDetails: Defines details of a cryptographic key pair. Parameters: - privKey?: string - pubKey: string - address: string - xPrivKey?: string - xPubKey?: string - KeyGenerationResult: Describes the result of key pair generation for Ethereum and Cosmos. Parameters: - mnemonic: string | undefined - ethKeyPair: KeyPairDetails - cosmosKeyPair: KeyPairDetails - VaultClientOptions: Configuration for the Vault client. Parameters: - pluginPath: string - vaultAddress: string - vaultToken: string - ApiGatewayConfig: Configuration for API Gateway access. Parameters: - apiId: string - stage: string - region: string - secretId: string - credentials: - accessKeyId: string - secretAccessKey: string - SctDetails: Defines details of a smart contract or token. Parameters: - address: string - owner: string - name: string - symbol: string - decimals: number - totalSupply: string - balances: Record[] - attachments: any[] # CLASS: SkcSctCms class_name: SkcSctCms description: Provides CMS interaction capabilities, Ethereum transaction signing, and data management. constructor: new SkcSctCms(baseUrl: string) methods: - login: Logs into CMS using API keys or credentials. Parameters: - Option 1 (API Key): - `apiKey`: string (API authentication key) - Option 2 (Email/Password): - `email`: string (User email address) - `password`: string (User password) - create: Creates a new record in a CMS collection. Parameters: - `collection`: string (Name of the collection) - `data`: object (Data fields and values to be created) - read: Reads records from a CMS collection with optional query parameters. Parameters: - `collection`: string (Name of the collection) - `query` (Optional): string (Query parameters for filtering) - update: Updates an existing record in the CMS. Parameters: - `collection`: string (Name of the collection) - `data`: object (Updated data fields) - `id`: string (Record identifier to update) - delete: Deletes a record in the CMS by ID. Parameters: - `collection`: string (Name of the collection) - `id`: string (Record identifier to delete) - setupUser: Sets up a CMS user using a mnemonic. Parameters: - `mnemonic`: string (BIP-39 mnemonic phrase) - `signerOption`: string (Signer type, e.g., "vault") - Option 1 (Signer Option is vault): - `mnemonic`: string (BIP-39 mnemonic phrase) - `signerOption`: string (Signer type, e.g., "vault") - Option 2 (Signer Option is aws): - `mnemonic`: string (BIP-39 mnemonic phrase) - `signerOption`: string (Signer type, e.g., "aws") - prepareTxTokenLedger: Prepares a transaction for journal operations. Parameters: - `methodName`: string - `args`: any (Method arguments) - `tokenLedgerId`: string - `memo` (Optional): string - prepareTxTokenType: Prepares a transaction for token operations. Parameters: - `methodName`: string - `args`: any (Method arguments) - `tokenTypeId`: string - `memo` (Optional): string - createTokenType: Creates a new SCT. Parameters: - `tokenName`: string - `category`: string - `itemId`: string - `denom`: string - `description`: string - `type`: string (e.g., "Mintable") - `initialSupply`: string - createTokenLedger: Creates a new Token Ledger. Parameters: - `ledgerName`: string - `description`: string - `tokenTypeOffset`: string - `uri`: string - `type`: string (e.g., "Locked") - signTx: Signs an Ethereum transaction. Parameters: - transactionData: object - `from`: string (Sender's Ethereum address) - `to`: string (Recipient's Ethereum address) - `data`: string (Encrypted transaction data) - `nonce`: string (Transaction nonce) - `gasLimit`: string (Maximum gas for transaction) - `chainId`: string (Blockchain network ID) - submitTx: Submits a signed Ethereum transaction (used for all signed transactions regardless of signing method). Parameters: - `signedTx`: object (Signed transaction object) - tokenLedgerDetails: Fetches details of a specific Token Ledger. Parameters: - `tokenLedgerId`: string (Token Ledger identifier) - tokenTypeDetails: Fetches details of a specific SCT. Parameters: - `tokenTypeId`: string (Token Type identifier) - encrypt: Encrypts text (used for all encryption queries). Parameters: - `plainText`: string # CLASS: SkcAws class_name: SkcAws description: Enables interaction with AWS's vault signer service constructor: new SkcAws(apiGatewayConfig: ApiGatewayConfig, offset?: string, isEncoded?: boolean, evmProvider?: ethers.Provider) implements: ApiGatewayConfig properties: - apiGatewayConfig: Gateway SDK to AWS lambda - offset: Offset used to sign a transaction/message - isEncoded: Check if message being sent is encoded - evmProvider: EVM provider to interact with contract Parameters: - `apiGatewayConfig`: ApiGatewayConfig object - `apiId`: string - `stage`: string - `region`: string - `secretId`: string - `credentials`: { - `accessKeyId`: string - `secretAccessKey`: string } - `offset` (Optional): string - `isEncoded` (Optional): boolean - `evmProvider` (Optional): ethers.Provider methods: - signTransaction: Signs transaction on AWS Parameters: - `transactionData`: object - `from`: string - `to`: string - `data`: string - `nonce`: string - `gasLimit`: string - `chainId`: string - signMessage: Signs ECDSA message on AWS Parameters: - `message`: string # CLASS: SkcVault class_name: SkcVault description: Enables interaction with Skuchain's vault signer service constructor: new SkcVault(kmsOptions: VaultClientOptions, offset: string, evmProvider?: ethers.Provider) properties: - kmsOptions: Vault configurations and credentials - offset: Offset used for signing - evmProvider: EVM provider for contract interaction Parameters: - `kmsOptions`: VaultClientOptions object - `pluginPath`: string - `vaultAddress`: string - `vaultToken`: string - `offset`: string - `evmProvider` (Optional): ethers.Provider methods: - storeMnemonic: Stores mnemonic in Vault Parameters: - `mnemonic`: string (BIP-39 mnemonic phrase) - connect: Connects signer to specified provider Parameters: - `provider`: ethers.Provider - getAddress: Retrieves vault address - getNonce: Gets transaction nonce Parameters: - `blockTag`: string - populateCall: Populates transaction data without sending Parameters: - `callData`: object - `to`: string - `data`: string - populateTransaction: Populates transaction object Parameters: - `tx`: object of transaction request - estimateGas: Estimates required gas Parameters: - `gasEstimationData`: object - `to`: string - `data`: string - call: Executes read-only transaction Parameters: - `tx`: object of transaction request - resolveName: Resolves ENS name to address Parameters: - `name`: string - sendTransaction: Sends signed transaction Parameters: - `transactionData`: object - `from`: string - `to`: string - `data`: string - `nonce`: string - `gasLimit`: string - `chainId`: string - signTransaction: Signs transaction request Parameters: - `transactionData`: object - `from`: string - `to`: string - `data`: string - `nonce`: string - `gasLimit`: string - `chainId`: string - signMessage: Signs ECDSA message Parameters: - `message`: string - signTypedData: Signs typed data (EIP-712) Parameters: - `domain`: any - `types`: any - `value`: any - TypedDataSigner: Signs typed data (EIP-712) Parameters: - `domain`: any - `types`: any - `value`: any # CLASS: SkcPrivacyService class_name: SkcPrivacyService description: Interface for interacting with privacy service constructor: new SkcPrivacyService(baseUrl: string) implements: [Database, Privacy Service] properties: - baseUrl: CMS base URL methods: - login: Authenticates user with email/password or API key Parameters: - Option 1 (API Key): - `apiKey`: string (API authentication key) - Option 2 (Email/Password): - `email`: string (User email address) - `password`: string (User password) - decrypt: Decrypts ciphertext for specified asset (used for decrypting all encrypted message) Parameters: - `cipherText`: string - `assetId`: string - `assetType`: string # CLASS: Sct class_name: Sct description: Interface for interacting with Supply Chain Token (SCT) constructor: new Sct(database: Database, id: string) properties: - database: Database instance - id: SCT identifier Parameters: - `database`: object - create: object - collectionName: string - data: any - read: object - collectionName: string - query (Optional): string - update: object - collectionName: string - updateData: any - key: string - delete: object - collectionName: string - query: any static_methods: - prepareDeployTx: Prepares CREATE2 contract deployment Parameters - `provider`: string - `signerAddress`: string - `idPredictionOptions`: object - `admin`: string - `tokenName`: string - `tokenSymbol`: string - `initialSupply`: string - `offset`: string - `skucodeType`: string - `factoryAddress`: string - generateSalt: Generates sha256 hash of input Parameters: - `input`: string # CLASS: TokenLedger class_name: TokenLedger description: Interface for interacting with token ledger constructor: new TokenLedger(database: Database, id: string) properties: - database: Database instance - id: Token ledger identifier Parameters: - `database`: object - create: object - collectionName: string - data: any - read: object - collectionName: string - query (Optional): string - update: object - collectionName: string - updateData: any - key: string - delete: object - collectionName: string - query: any static_methods: - prepareDeployTx: Prepares CREATE2 contract deployment Parameters - `provider`: string - `signerAddress`: string - `idPredictionOptions`: object - `admin`: string - `tokenName`: string - `tokenSymbol`: string - `initialSupply`: string - `offset`: string - `skucodeType`: string - `factoryAddress`: string - generateSalt: Generates sha256 hash of input Parameters: - `input`: string # CLASS: SkucodeContract class_name: SkucodeContract description: Extends ethers.Contract to provide interface for interacting with smart contract constructor: new SkucodeContract(target: string, contractRunner: Signer | Provider) properties: - target: Contract address, ENS name or any Addressable - contractRunner: Signer or Provider for contract interactions methods: - prepareTxData: Prepares transaction data for contract method Parameters: - `methodName`: string - `args`: any[] - `signerAddress`: string - `memo`: string (Optional) Returns: Promise - getName: Gets token name Returns: string - getSymbol: Gets token symbol Returns: string - getOwner: Gets owner's address Returns: string - getDecimals: Gets token decimals Returns: number - getTotalSupply: Gets total token supply Returns: string - getBalance: Gets balance for address Parameters: - `address`: string Returns: string - getBalances: Gets all address balances from Transfer events Returns: Array<{ accountAddress: string, balance: string }> - getAttachments: Gets AttachmentAdded events Returns: Array<{ cid: string, submitter: string }> - getDetails: Gets all token details Returns: Promise # CLASS: SkucodeFactoryContract class_name: SkucodeFactoryContract description: Extends ethers.Contract to provide factory contract interface constructor: new SkucodeFactoryContract(target: string, contractRunner: Signer | Provider) properties: - target: Contract address, ENS name or any Addressable - contractRunner: Signer or Provider for contract interactions methods: - prepareTxData: Prepares transaction data for contract method Parameters: - `methodName`: string - `args`: any[] - `signerAddress`: string - `memo`: string (Optional) Returns: Promise # CLASS: SkusetContract class_name: SkusetContract description: Extends ethers.Contract to provide interface for interacting with smart contract constructor: new SkusetContract(target: string, contractRunner: Signer | Provider) properties: - target: Contract address, ENS name or any Addressable - contractRunner: Signer or Provider for contract interactions methods: - prepareTxData: Prepares transaction data for contract method Parameters: - `methodName`: string - `args`: any[] - `signerAddress`: string - `memo`: string (Optional) Returns: Promise - getAttachments: Gets AttachmentAdded events Returns: Array - getTokens: Gets balances from TransferSingle and TransferBatch events Returns: any - getOwner: Gets owner's address Returns: string - pauseState: Gets contract pause state Returns: boolean - getDetails: Gets all token details Returns: any # CLASS: SkusetFactoryContract class_name: SkusetFactoryContract description: Extends ethers.Contract to provide factory contract interface constructor: new SkusetFactoryContract(target: string, contractRunner: Signer | Provider) properties: - target: Contract address, ENS name or any Addressable - contractRunner: Signer or Provider for contract interactions methods: - prepareTxData: Prepares transaction data for contract method Parameters: - `methodName`: string - `args`: any[] - `signerAddress`: string - `memo`: string (Optional) Returns: Promise # LANGUAGE language: TypeScript # SCRIPTS scripts: | # Example: Logging into the CMS const cms = new sdk.SkcSctCms("https://example.com"); await cms.login({ apiKey: "your-api-key"}); (OR) await cms.login({email: "your-email-id", password: "your-password"}) const cms = new sdk.SkcSctCms("http://localhost:3002"); await cms.login({ apiKey: "726eeab6-75ce-457d-af3f-6e71b3de72dd"}); (OR) await cms.login({email: "admin@skuchain.com", password: "admin@123"}) # Example: Creating a CMS record await cms.create("collection-name", "Data fields and their values"); const newRecord = await cms.create("transactions", { hash: "0x7d2bb304d51b99e614ac8f953f54d8aa3b2cc388a598efe00b86ce2bf0431aaa", action: "transfer", memo: "redeeming discounts on spares used in oct 24", sender: "6731f8377c28366067c4d505", Assets: "0x492606796908204b1858edB0FE7968BA04d28E1c" }); # Example: Fetching CMS records await cms.read("collection-name", "query(Optional)"); const records = await cms.read("transactions", "limit=2"); # Example: Updating CMS records await cms.update("collection-name", "Data to be Updated", "Id"); await cms.update("transactions", { memo: "redeeming discounts" }, "673c3993363b8aed64dda160"); # Example: Deleting CMS records await cms.delete("collection-name", "Id"); await cms.delete("transactions", "673c3993363b8aed64dda160"); # Example: User Setup // Use Vault signer option const user = await cms.setupUser("mnemonic", "vault"); // Use AWS signer option const user = await cms.setupUser("mnemonic", "aws"); const user = await cms.setupUser("liar spend east depth advice float punch grace cigar angle pulse soup","vault"); # Example: Signing a transaction const signedTx = await cms.signTx({ from: "0xYourAddress", to: "0xRecipientAddress", data: "Encrypted data", nonce: "0", gasLimit: "100000", chainId: "31337" }); const txData = { from: "0x86F0e1dD8AA610d607401b5E01C435A72EE5DFA2", to: "0xa02b17E60f4949D82Eb3A1B2FE6b1501D6344D59", data: "3cf018042a7be282fb2916bbfe383f710398812a435aaeee9bf172100d4a31309317e46e6d16f0bd6fc0d3df9891f7b1b0e254c7dcfbc5e2876f57a2bd6b891f5cc1217926aedd2e4ef3409ac016aa8a731e816e03516dbf25b8f3f13ea05a3abe906488fb4274d481ae8e0acef8600596", nonce: "0", gasLimit: "100000", chainId: "31337", }; const signedTx = await cms.signTx(txData); # Example: Submitting a signed transaction const txHash = await cms.submitTx(signedTx); # Example: Creating Token Type: await cms.createTokenType( "Token-Name", "Category", "Item-id", "Denom", "Description", "Type", "Initial-Supply" ); const tokenType = await cms.createTokenType( "Mike-500", "line-of-credit", "BL-2024", "USD", "0", "Mintable", "1000000" ); # Example: Creating Token Ledger: await cms.createTokenLedger( "Ledger-Name", "Description", "Offset of TokenType", "Uri", "Type" ); const tokenLedger = await cms.createTokenLedger( "lask", "Ledger for ExampleToken", "78421a14-6cfb-4880-88e1-07be4fb04ce3", "test", "Locked" ); # Example: Fetching Token Type: await cms.tokenTypeDetails("Token-Type-Id"); const tokenTypeDetails = await cms.tokenTypeDetails("0xC73D57804c3f7049b643a2414134730496fb0293"); # Example: Fetching Token Ledger: await cms.tokenLedgerDetails("Token-Ledger-Id"); const ledgerDetails = await cms.tokenLedgerDetails("0x62212De795f8d22bd642d72330cF872172C73D8e"); # Example: Preparing Token Ledger Transaction: await cms.prepareTxTokenLedger( "Method-Name", "args", "Token-Ledger-Id", "Memo(Optional)" ); # Example: Preparing Token Type Transaction: await cms.prepareTxTokenType( "Method-Name", "args", "Token-Type-Id", "Memo(Optional)" ); # Example: Encrypt a message: await cms.encrypt("Message"); # Example: Create a User: import {SkcSctCms, generateKeys} from "skc-sct-sdk"; const cms = new sdk.SkcSctCms("https://example.com"); await cms.login({ apiKey: "your-api-key"}); (OR) await cms.login({email: "your-email-id", password: "your-password"}) const keys = await generateKeys(); // Use Vault signer option const user = await cms.setupUser(keys.mnemonic, "vault"); // Use AWS signer option const user = await cms.setupUser(keys.mnemonic, "aws"); # Example: Keys Generation import { generateKeys } from "skc-sct-sdk" // Generate new keys with random mnemonic const keys = generateKeys(); // Generate keys with specific mnemonic and path const keysWithParams = generateKeys( "test test test test test test test test test test test test", "m/44/0" ); # Example: HD Address Index Generation import { generateHdAddressIndex } from "skc-sct-sdk" const addressIndex = generateHdAddressIndex("555d9159-bb35-40ea-bd8a-42dcd32649c4") # Example: Single Use Eth Public Key Generation import { generateSingleUseEthPubKey } from "skc-sct-sdk" const singleUseKey = generateSingleUseEthPubKey( "0x03364d3db1a3d49a53432473d953d680be3eebdae6775b243c2087b9ae92431f1a", "555d9159-bb35-40ea-bd8a-42dcd32649c4" ) # Example: AWS Signing and Transaction Submission const awsConfig = { apiId: "api-id", stage: "prod", region: "aws-region", secretId: "secret-id", credentials: { accessKeyId: "access-key", secretAccessKey: "secret-key" } }; const aws = new SkcAws(awsConfig, "offset", "message encoded or not"); const signedAwsTx = await aws.signTransaction({ from: "0xYourAddress", to: "0xRecipientAddress", data: "Encrypted data", nonce: "0", gasLimit: "100000", chainId: "31337" }); // Submit the AWS-signed transaction using cms.submitTx const txHash = await cms.submitTx(signedAwsTx); const signedAwsMessage = await aws.signMessage("message"); # Example: Vault Signing and Transaction Submission const vault = new SkcVault({ pluginPath: "/path/to/plugin", vaultAddress: "http://vault.example.com", vaultToken: "vault-token" }, "offset"); const vaultSignedTx = await vault.signTransaction({ from: "0xYourAddress", to: "0xRecipientAddress", data: "Encrypted data", nonce: "0", gasLimit: "100000", chainId: "31337" }); // Submit the Vault-signed transaction using cms.submitTx const vaultTxHash = await cms.submitTx(vaultSignedTx); const vaultSignedMsg = await vault.signMessage("Message"); # Example: Vault Operations: // Store Mnemonic in Vault: await vault.storeMnemonic("mnemonic phrase"); // Connect to Provider with Vault: await vault.connect(provider); // Get Address using Vault: const vaultAddress = await vault.getAddress(); // Get Nonce using Vault: const nonce = await vault.getNonce(); // Populate Call using Vault: const populatedCall = await vault.populateCall({ to: "0xContract", data: "0x123" }); // Gas Estimation using Vault: const gasEstimate = await vault.estimateGas({ to: "0xContract", data: "0x123" }); // Call a contract using Vault: const callResult = await vault.call({ to: "0xContract", data: "0x123" }); // Resolve a Name using Vault: const resolvedName = await vault.resolveName("example.eth"); // Send a Transaction using Vault: const vaultTx = await vault.sendTransaction({ from: "0xYourAddress", to: "0xRecipientAddress", data: "Encrypted data", nonce: "0", gasLimit: "100000", chainId: "31337" }); // Sign a Typed Data using Vault: const vaultSignedTypedData = await vault.signTypedData( "domain", "types", "value" ); // Typed Data signing using Vault: const vaultTypedDataSigner = await vault.TypedDataSigner( "domain", "types", "value" ); # Example: Login into Privacy service: import { SkcPrivacyService } from "skc-sct-sdk"; const privacy = new SkcPrivacyService("https://privacy.example.com"); await privacy.login({ apiKey: "your-api-key" }); (OR) await privacy.login({email: "your-email-id", password: "password"}); import { SkcPrivacyService } from "skc-sct-sdk"; const privacy = new SkcPrivacyService("https://skc-privacy-service.skutron.com"); await privacy.login({ apiKey: "726eeab6-75ce-457d-af3f-6e71b3de72dd" }); (OR) await privacy.login({email: "privacy@skuchain.com", password: "privacy123"}); # Example: Decrypt a encrypted message using Privacy service: import { SkcPrivacyService } from "skc-sct-sdk"; const privacy = new SkcPrivacyService("https://privacy.example.com"); const decryptedText = await privacy.decrypt("cipherText", "assetId", "assetType"); # Example: Prepare and Deploy Transaction in SCT: import { Sct } from "skc-sct-sdk"; const database = { create: { collectionName: "sct", data: "Data fields and their values }, read: { collectionName: "sct", query: "limit=2" }, update: { collectionName: "sct", updateData: "data to be updated", key: "Id" }, delete: { collectionName: "sct", query: "Id" } } const sct = new Sct(database, "sctId"); const sctConfig = { provider: "http://localhost:8545", signerAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", idPredictionOptions: { admin: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", tokenName: "Supply Chain Token", tokenSymbol: "SCT", initialSupply: "1000000000000000000000000", offset: "0", skucodeType: "Mintable", factoryAddress: "0x1234567890123456789012345678901234567890" } }; const deployTx = await sct.prepareDeployTx(sctConfig.provider, sctConfig.signerAddress, sctConfig.idPredictionOptions); # Example: Generate Salt using SCT: import { Sct } from "skc-sct-sdk"; const sct = new Sct(database, "sctId"); const salt = await sct.generateSalt("input-string"); # Example: Prepare and Deploy Transaction in TokenLedger: import { TokenLedger } from "skc-sct-sdk"; const database = { create: { collectionName: "sct", data: "Data fields and their values }, read: { collectionName: "sct", query: "limit=2" }, update: { collectionName: "sct", updateData: "data to be updated", key: "Id" }, delete: { collectionName: "sct", query: "Id" } } const tokenLedger = new TokenLedger(database, "ledgerId"); const ledgerConfig = { provider: "http://localhost:8545", signerAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", idPredictionOptions: { admin: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", tokenName: "Supply Chain Token", tokenSymbol: "SCT", initialSupply: "1000000000000000000000000", offset: "0", skucodeType: "Mintable", factoryAddress: "0x1234567890123456789012345678901234567890" } }; const ledgerDeployTx = await tokenLedger.prepareDeployTx(ledgerConfig.provider, ledgerConfig.signerAddress, ledgerConfig.idPredictionOptions); # Example: Generate Salt using TokenLedger: const tokenLedger = new TokenLedger(database, "ledgerId"); const salt = await tokenLedger.generateSalt("input-string"); # Example: Prepare Transaction Data import { utils } from "skc-sct-sdk"; const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const contract = new ethers.Contract(contractAddress, contractAbi, provider); const txData = await utils.prepareTxData(contract, "transfer", [recipientAddress, amount], "0xYourSignerAddress", provider, "Payment for services"); # Example: Prepare Ether Transfer Data import { utils } from "skc-sct-sdk"; const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const txData = await utils.prepareEthTransferTxData("0xSenderAddress", "0xRecipientAddress", "1.0", provider); # Example: Decode Transaction Memo import { utils } from "skc-sct-sdk"; const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const contract = new ethers.Contract(contractAddress, contractAbi, provider); const memo = await utils.retrieveMemoFromTxHash(contract, "0xTransactionHash", provider); # Example: Safe BigInt to Number import { utils } from "skc-sct-sdk"; const safeNumber = utils.safeBigIntToNumber(BigInt("12345678901234567890")); # Example: Trim Null Characters from String import { utils } from "skc-sct-sdk"; const trimmedString = utils.trimNullCharacters("Hello World\u0000\u0000"); # Example: Check Valid Date import { utils } from "skc-sct-sdk"; const isValid = utils.isValidDate(1672531199); # Example: Filter Events by Identity import { utils } from "skc-sct-sdk"; const events = [ { identity: "user1", event: "login" }, { identity: "user2", event: "logout" } ]; const filteredEvents = utils.filterEventsByIdentity(events, "user1"); # Example: Convert Ethereum Address to Decimal import { utils } from "skc-sct-sdk"; const decimalAddress = utils.ethereumAddressToDecimal("0xD29f5A8C0D445aF98674801f0b944Dc7F4b92D67"); # Example: Decode Logs from Transaction Receipt import { utils } from "skc-sct-sdk"; const decodedLogs = utils.decodeLogsFromReceipt(receipt); # Example: Get Events from ABI: import { utils } from "skc-sct-sdk"; const eventsFromAbi = utils.getEventsFromAbi(contractAbi); # Example: Get Event structures from ABI Events: import { utils } from "skc-sct-sdk"; const eventStructure = utils.getEventStruct(ABI_Events); # Example: Replaces BigInt number with string representation: import { utils } from "skc-sct-sdk"; const valueReplacer = utils.replacer("key",BigInt("12345678901234567890")); # Example: Generate Random Listing ID import { utils } from "skc-sct-sdk"; const listingId = utils.generateRandomListingId(); # Example: Generate Offer ID import { utils } from "skc-sct-sdk"; //Without length const offerId = utils.generateOfferId(); // With length const offerId = utils.generateOfferId(length: 8); # Example: Fund Account from Faucet import { utils } from "skc-sct-sdk"; await utils.fundAccount("https://faucet.example.com", "0xRecipientAddress"); # Example: Transform Data Store: import { utils } from "skc-sct-sdk"; const dataStoreTransform = utils.transformDatastore("users"); # Example: Pass refutation period: import { utils } from "skc-sct-sdk"; const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const refutationPass = utils.passRefutationPeriod(provider); # Example: Get Account Balance: import { utils } from "skc-sct-sdk"; const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const accountBalance = utils.getAccountBalance("0xAddress",provider); # Example: Validates Contract or Not: import { utils } from "skc-sct-sdk"; const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const isContractOrNot = utils.isContract("0xContractAddress",provider); # Example: Validates Zip File or Not: import { utils } from "skc-sct-sdk"; const isZipFileOrNot = utils.isZipFile("zipFileBuffer"); # Example: Verify Signature import { utils } from "skc-sct-sdk"; const isValidSignature = utils.verifySignature("0xSignatureString", "Message to verify", "0xSignerAddress"); # Example: SkucodeContract Operations import { ethers } from 'ethers'; import { SkucodeContract } from 'skc-sct-sdk'; // Initialize provider and contract const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const signer = provider.getSigner(); // Using Provider for skucodeContract Initialization const skucodeContract = new SkucodeContract("0xContractAddress", provider); // Using Signer for skucodeContract Initialization const skucodeContract = new SkucodeContract("0xContractAddress", signer); // Get Name of Skucode const tokenName = await skucodeContract.getName(); // Get Symbol of Skucode const tokenSymbol = await skucodeContract.getSymbol(); // Get Owner of Skucode const tokenOwner = await skucodeContract.getOwner(); // Get Decimals of Skucode const decimals = await skucodeContract.getDecimals(); // Get total supply of Skucode const totalSupply = await skucodeContract.getTotalSupply(); // Get balance of single user in skucode const balance = await skucodeContract.getBalance("0xUserAddress"); // Get all balances of user in skucode const allBalances = await skucodeContract.getBalances(); // Get Attachments const attachments = await skucodeContract.getAttachments(); // Get Complete Token Details const tokenDetails = await skucodeContract.getDetails(); // Prepare Transaction Data const transferTxData = await skucodeContract.prepareTxData( "transfer", ["0xRecipientAddress", "1000"], "0xSignerAddress", "Transfer memo" ); # Example: SkucodeFactoryContract Operations import { ethers } from 'ethers'; import { SkucodeFactoryContract } from 'skc-sct-sdk'; // Initialize provider and factory contract const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const signer = provider.getSigner(); // Using Provider for skucodeFactoryContract Initialization const factoryContract = new SkucodeFactoryContract("0xFactoryAddress", provider); // Using Provider for skucodeFactoryContract Initialization const factoryContract = new SkucodeFactoryContract("0xFactoryAddress", signer); // Prepare Transaction Data for Token Creation const createTokenTxData = await factoryContract.prepareTxData( "createToken", ["Token Name", "TKN", "1000000"], "0xSignerAddress", "Create token memo" ); // Prepare Transaction Data for Other Factory Operations const factoryTxData = await factoryContract.prepareTxData( "someFactoryMethod", ["param1", "param2"], "0xSignerAddress", "Operation memo" ); # Example: SkusetContract Operations import { ethers } from 'ethers'; import { SkusetContract } from 'skc-sct-sdk'; // Initialize provider and contract const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const signer = provider.getSigner(); // Using Provider for skusetContract Initialization const skusetContract = new SkusetContract("0xContractAddress", provider); // Using Signer for skusetContract Initialization const skusetContract = new SkusetContract("0xContractAddress", signer); // Get Owner for skuset const owner = await skusetContract.getOwner(); // Pause state for skuset const isPaused = await skusetContract.pauseState(); // Get Details for skuset const contractDetails = await skusetContract.getDetails(); // Get Tokens and Attachments const tokens = await skusetContract.getTokens(); const attachments = await skusetContract.getAttachments(); // Prepare Transaction Data const mintTxData = await skusetContract.prepareTxData( "mint", ["0xRecipientAddress", "1", "1000"], "0xSignerAddress", "Mint memo" ); const transferTxData = await skusetContract.prepareTxData( "safeTransferFrom", ["0xFromAddress", "0xToAddress", "1", "100", "0x"], "0xSignerAddress", "Transfer memo" ); # Example: SkusetFactoryContract Operations import { ethers } from 'ethers'; import { SkusetFactoryContract } from 'skc-sct-sdk'; // Initialize provider and factory contract const provider = new ethers.JsonRpcProvider("http://localhost:8545"); const signer = provider.getSigner(); // Using Provider for skusetFactoryContract Initialization const factoryContract = new SkusetFactoryContract("0xFactoryAddress", provider); // Using Signer for skusetFactoryContract Initialization const factoryContract = new SkusetFactoryContract("0xFactoryAddress", signer); // Prepare Transaction Data for Token Set Creation const createTokenSetTxData = await factoryContract.prepareTxData( "createTokenSet", ["Token Set Name", "uri://metadata", true], "0xSignerAddress", "Create token set memo" ); // Prepare Transaction Data for Other Factory Operations const factoryOperationTxData = await factoryContract.prepareTxData( "someFactoryMethod", ["param1", "param2"], "0xSignerAddress", "Operation memo" ); # DEBUGGING - Issue: Transactions failing due to insufficient gas. Solution: Increase the `gasLimit` parameter or use the `estimateGas` method. - Issue: Login credentials not working. Solution: Double-check the API key or email/password combination. Ensure the user is registered in the CMS. - Issue: Blockchain connection errors. Solution: Verify the `RPC_URL` and ensure network connectivity. # LINKS docs_url: https://docs.skc-sct-sdk.example.com github_repo: https://github.com/skuchain/skc-sct-sdk support_email: support@skuchain.com