Skip to content

Encrypt a String, Salt Generation and Fetch Transaction Memo

To encrypt a string, generate a salt, and get a transaction memo using the skc-trade-sdk, you can follow these steps:

Encrypting a String:

  • Use the encrypt function from the skc-trade-sdk to encrypt a plaintext message using the public key of the counterparty.
javascript
import { encrypt } from "skc-trade-sdk";
const encryptedMessage = await encrypt("This is a secret message", "0xCounterPartyPublicKey");

Generating a Salt:

  • Use the generateSalt function from the utils module of the skc-trade-sdk to generate a SHA-256 hash of the input string.
javascript
import { utils } from "skc-trade-sdk";
const salt = await utils.generateSalt("your-input-string");

Getting a Transaction Memo:

  • Use the getTxMemo method from the TradeCms class to fetch the memo of a transaction using its hash.
javascript
import { TradeCms } from "skc-trade-sdk";
const cms = new TradeCms("https://example.com");
const txMemo = await cms.getTxMemo("transaction-hash");

By following these steps, you can encrypt a string, generate a salt, and retrieve a transaction memo using the skc-trade-sdk.