
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
milkomeda-wsc
Advanced tools
A Typescript library to easily interact with Milkomeda's Wrapped Smart Contracts (WSC)
Wrapped Smart Contracts are a new concept aimed at facilitating interaction with smart contracts on sidechains or Layer 2 (L2) solutions without the need for users to directly migrate to these new ecosystems. The Layer 1 (L1) blockchain acts as a robust coordination layer, allowing users to execute smart contracts on sidechains or L2 while remaining on the L1 blockchain. This provides a user-friendly experience, as users can interact with various systems without changing wallets or needing a deep understanding of the underlying processes.
WSCLib is a TypeScript library designed to simplify interactions with Wrapped Smart Contracts (WSCs). Leveraging the novel concept of WSCs, this library brings the flexibility of executing smart contracts on sidechains or Layer 2 (L2) networks without users needing to leave their Layer 1 (L1) environment. This seamless experience eliminates the need for wallet switching or understanding the underlying complexities, offering a new user experience paradigm for blockchain interactions.
WSCLib provides a rich set of features to interact with WSCs:
Install the library using npm:
npm install milkomeda-wsc
Here's how you can use WSCLib in your project:
import WSCLib, { UserWallet, MilkomedaNetworkName } from 'milkomeda-wsc';
const network = MilkomedaNetworkName.C1Mainnet;
const wallet = "flint"; // replace with the cip30 wallet type of your choice
const oracleUrl = 'oracleUrl'; // replace with the URL for your Oracle
const jsonRpcProviderUrl = 'jsonRpcProviderUrl'; // replace with your RPC URL
const blockfrostKey = 'blockfrostKey'; // replace with your blockfrost key
const wscLib = new WSCLib(network, wallet, {
oracleUrl,
jsonRpcProviderUrl,
blockfrostKey
});
// Inject the library with the necessary dependencies
await wscLib.inject();
const balance = await wscLib.origin_getNativeBalance();
console.log(balance); // logs the user's native balance
The origin_getNativeBalance() method returns a Promise. The resolved string represents the user's native balance.
The WSCLib is a class designed to interact with the blockchain and handle token management.
constructor
isCardano
isAlgorand
origin_getTokenBalances(address: string | undefined)
address
(string, optional): The address for which to retrieve token balances.OriginAmount
objectscardano_origin_getTokenBalances(address: string | undefined)
address
(string, optional): The address for which to retrieve token balances.OriginAmount
objectsalgorand_origin_getTokenBalances(address: string | undefined)
address
(string, optional): The address for which to retrieve token balances.OriginAmount
objectsalgo_updateAssetsWithBridgeInfo(tokens: OriginAmount[])
tokens
(Array of OriginAmount
objects): The tokens to update.OriginAmount
objectsada_updateAssetsWithBridgeInfo(tokens: OriginAmount[])
tokens
(Array of OriginAmount
objects): The tokens to update.OriginAmount
objectsareTokensAllowed(assetIds: string[])
assetIds
(Array of strings): The asset IDs to check.constructAllowedTokensMap(normalizedAssetIds: string[], isAssetAllowed: (asset: any) => boolean)
normalizedAssetIds
(Array of strings): The asset IDs to map.isAssetAllowed
(Function): Callback to determine if an asset is allowed.cardano_areTokensAllowed(assetIds: string[])
assetIds
(Array of strings): The asset IDs to check.algorand_areTokensAllowed(assetIds: string[])
assetIds
(Array of strings): The asset IDs to check.wrap(destination: string | undefined, assetId: string, amount: number)
destination
(string, optional): The destination for the tokens.assetId
(string): The ID of the asset to wrap.amount
(number): The amount of the asset to wrap.unwrap(destination: string | undefined, assetId: string, amount: BigNumber)
destination
(string, optional): The destination for the tokens.assetId
(string): The ID of the asset to unwrap.amount
(BigNumber): The amount of the asset to unwrap.latestActivity()
Activity
objectsgetL2TransactionList(address: string | undefined, page = 0, offset = 10)
address
(string, optional): The address for which to retrieve transactions.page
(number, default is 0): The page number for pagination.offset
(number, default is 10): The offset number for pagination.L2Transaction
objectsIn-depth method descriptions, usage examples, and return types can be found in the library's codebase. If further information is required, please reach out to us. We're dedicated to making WSCLib a robust and easy-to-use solution for developers working with WSCs.
WSCLib is open for contributions. We encourage you to contribute to WSCLib and help us improve this library.
WSCLib is MIT licensed.
FAQs
A Typescript library to easily interact with Milkomeda's Wrapped Smart Contracts (WSC)
The npm package milkomeda-wsc receives a total of 3 weekly downloads. As such, milkomeda-wsc popularity was classified as not popular.
We found that milkomeda-wsc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.