@hemergy/core-sdk
v0.0.28
Published
TypeScript NPM Module for Hemergy Core
Keywords
Readme
Hemergy SDK
Usage
import Hemergy from '@hemergy/core-sdk'
const signer = await ethersProvider.getSigner(); // ethers signer to be used in all endpoint calls as endUserAddress
const hemergy = new Hemergy({ baseURL: 'https://dev-core.hemergy.com', signer });
const account = await hemergy.createAccount(); // Create an account managed by the signer
const isKYCed = await hemergy.isKYCed(account); // Check if the account is KYCed
const project = await hemergy.createProject(account, [], [], totalSupply, tokenPrice, 'ipfs://...', midcap); // Create a project under an account. Note: the account should be KYCed
API
| Function | Description |
| ----------- | ----------- |
| getMeta | Load addresses and ABIs from Core (/meta), cached on the instance |
| getContracts | Return the ethers contracts to interact with |
| getProjectContract | Return a Project contract at an address |
| getSignerAddress | Return the signer address |
| createAccount | Create an account signer by the signer |
| isKYCed | Check if the account is KYCed |
| createProject | Create a project under a specific account |
| depositToAccount | Deposit tokens into the Hemergy Account |
| approveAccountAmount | Approve an amount from the account to a spender |
| setAccountURI | Update the account URI |
| permitToken | Permit flow: payload, sign, execute via Core |
| approveTokenDirectly | ERC20 approve from the user wallet (user pays gas) |
| investInProject | Allow an investor to invest in a project |
| divestInProject | Allow an investor to divest in a project |
| kickstartProject | Kickstart a project |
| closeFundraise | Close fundraise; then Core calls payBeneficiaries |
| approveRefundProtection | Approve security token for refund flow when needed |
| cancelProjectDirect | Call cancelProject on-chain (direct tx, not relayer) |
| withdrawTokens | Withdraw energy tokens via revenue contract |
| withdrawUSDC | Withdraw USDC via revenue contract |
| mint | Get some amount in user account (Only available in dev and testnet environment ) |
| mintAmount | Mint a specific amount (dev / controlled environments) |
| getBalance | Get balance of user account (Only available in dev and testnet environment ) |
| getProjects | List project addresses from the factory |
| getProjectTotalGeneratedEnergy | Read total generated energy for a project |
| getInvestorTotalGeneratedEnergy | Read investor energy total for a project |
