bunzz-sdk
v1.2.4
Published
Bunzz SDK is deprecated and no longer maintained.
Downloads
13
Readme
!!!CAUTION!!!
Bunzz SDK is deprecated and no longer maintained.
Bunzz SDK
Bunzz SDK is a client-side library to interact with smart contracts deployed by Bunzz. For more details, check out the documentation.
Installation
yarn add bunzz-sdk
npm i bunzz-sdk --save
Or
<script src="https://cdn.jsdelivr.net/npm/bunzz-sdk/lib/index.iife.js"></script>
Simple Usage
import bunzz from 'bunzz-sdk';
// Set your keys
const DAPP_ID = "Your DApp ID";
const API_KEY = "Your API Key";
// Initialize SDK
const handler = await bunzz.init({
dappId: DAPP_ID,
apiKey: API_KEY,
});
// Get a contract object
const MODULE_NAME = 'Token (ERC20)';
const erc20 = handler.getContract(MODULE_NAME);
// Connect to wallet
const connect = async () => {
await handler.connectWallet();
console.log("Connected to the wallet");
}
// Example of "Update Action"
const mint = async (to, amount) => {
const signerAddress = await handler.getAddress();
const tx = await erc20.mint(to, amount);
const receipt = await tx.wait();
console.log(receipt.events);
console.log('Token successfully minted! Congratulation 🎉');
};
// Example of "Read Action"
const getBalance = async (address) => {
const res = await erc20.balanceOf(address);
console.log(`The ${address}'s balance is ${res.data}`);
};