stbl-sdk v0.4.4
About The Project
Why use this sdk?
- You shouldn't creating the same tasks over and over like creating instances or handling amounts. :smile:
Build With
Getting Started
stbl-sdk is a JavaScript SDK or a API wrapper for the vault contract using usdc.
stbl-sdk simplify the process of minting and withdrawing the cash from the vault.
It is a simple, easy to use, and powerful API for interacting with Stbl Protocol.
You can use Stbl-sdk on node server, browser, or mobile.
You can install stbl-sdk either using NPM .
Inside your project directory, run the following command:
npm install stbl-sdk@0.4.4
Usage
Using stbl-sdk is way easier, you can import the library in your project and use it.
import { stblsdk } from "stbl-sdk";
API Operation
Here is an example of how to mint the $CASH:
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
const web3 = createAlchemyWeb3(alchemyKey);
1) Check allowance of $USDC on the vault address using
let allowance = await stblsdk.allowanceCheck(web3,walletAddress)
2) If allowance is not sufficient call approve function using
const tx = Promise.resolve(
await stblsdk.ApproveVault(web3,amount,walletAddress)
);
tx.then((res) => {
console.log(res);
});
3) Mint $CASH using $USDC
const tx = Promise.resolve(
await stblsdk.Mint(web3, amount, walletAddress)
);
tx.then((res) => {
console.log(res);
});
// amount = the amount of $USDC you want to exchange for $CASH
// walletAddress = account which will be doing the transaction
// web3 is an instance of web3 show be polygon mainnet rpc in alchemy key
Here is an example of how to withdraw the $CASH:
````js
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
const web3 = createAlchemyWeb3(alchemyKey);
1) Check the balance if its sufficient or not using
let balanceOf = await stblsdk.balanceOf(web3,walletAddress)
2) Withdraw Transaction
const tx = Promise.resolve(
await stblsdk.Withdraw(web3, amount, walletAddress)
);
tx.then((res) => {
console.log(res);
});
// amount = the amount of $CASH you want to exchange for $USDC
// walletAddress = account which will be doing the transaction
// web3 is an instance of web3 show be polygon mainnet rpc in alchemy key
### API Response
```json
{blockHash
:
"0x0621404b0df5cd83564c9cf0cc58fd5e88f8f0e8f0386f8c5d22072c5ec3c864"
blockNumber
:
39946647
contractAddress
:
null
cumulativeGasUsed
:
16659680
effectiveGasPrice
:
123340143261
from
:
"0x2cd9baace3f4d4ea9f246004914d7d0e666bbab3"
gasUsed
:
2587699
logs
:
(29) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
logsBloom
:
"0x0201005001000000000008000000000000800000000000000011000000000100000000000400010000110000004000010000800200000000000000001020000100000000000000000020080a04014982000200000000000008010008400000001000000002020000000000000000080000000000000c020180100018080004001001001000080000000000000002040000060010000000000000004000000000224004000081010000000000004000000000400000000000000080000000014480000802000000000021006008020000c80000000000880000100400800020000010009000002020600000000000010012000040000404000000000000100020"
status
:
true
to
:
"0xd1bb7d35db39954d43e16f65f09dd0766a772cff"
transactionHash
:
"0xe46df93ab1722fe80a7db353d70213ebfc8a50360a9cc445f1183865e51be4d3"
transactionIndex
:
78
}
License
Distributed under the Apache-2.0 License. See LICENSE
for more information.
Contact
Sanchit Dawar - sanchitdawar3
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago