@kanalabs/mirai
v0.2.8
Published
Mirai - Account Abstraction SDK (EVM + non-EVM)
Downloads
405
Maintainers
Readme
Mirai
Mirai - Account Abstraction SDK (EVM + non-EVM)
Installation
npm i @kanalabs/mirai
Supported Networks
Mainnets:
- AptosMainnet
- mainnet (Ethereum)
- polygon
- optimism
- linea
- gnosis
- mantle
- avalanche
- base
- bsc
- klaytn
- scroll
- flare
- bifrost
Testnets:
- AptosTestnet
- bscTestnet
- KlaytnTestnet
- ScrollSepolia
- FuseSparknet
- goerli
- mumbai
- sepolia
- flareTestnet
- bifrostTestnet
Available Properties in SDKGateway
| Properties | Description | | --------------- | ------------------------------------------------------- | | instances | Returns all initialized instances | | currentNetwork | Returns the current default network | | currentInstance | Returns the current default SDK instance | | contractAddress | Returns KanaWallet address for initialized chains | | walletProvider | Returns the wallet provider which used to init the sdk | | activeNetworks | Returns available networks with their respective status |
Available Methods in SDKGateway
| Methods | Description |
| --------------------------------------------------|--------------------------------------------------------|
| initialize(network?: NetworkNames) | To initialize the SDK instance specify a network,and |
| | and return the result of initialization. |
| getNativeBalance(network?: NetworkNames) | To get the native token balance of the smart wallet. |
| | Returns native token balance. |
| setCurrentInstance(network: NetworkNames) | To set the default SDK instance and retrieve the SDK |
| | instance associated with the specified network. |
| erc20(tokenAddress: string,network?: NetworkNames)| To get the ERC20 token instance for building ERC20 |
| | transactions. Returns the ERC20 contract instance. |
| erc721(collectionAddress: string, | To get the ERC721 collection instance for building |
| network?: NetworkNames) | ERC721 transactions.Returns the ERC721 contractinstance|
| erc1155(collectionAddress: string, | To get the ERC1155 collection instance for building |
| network?: NetworkNames) | ERC1155 transactions. Returns the ERC1155 contract
| | instance transactions.Returns the ERC721
| isNetworkActive(networkName: string): boolean | To check if the given network is available and active. |
| | Returns bool |
| | Example const isActive = isNetworkActive (networkName) |
| | transactions. Returns the ERC20 contract instance. |
| getProvider(network: NetworkNames) | To get the RPC Provider for the given network. |
| providers.JsonRpcProvider | Returns providers.JsonRpcProvider |
| | Example const provider = getProvider(networkName) |
| destroy(network: NetworkNames) | To destroy the SDK instance specifying a network for |
| | destruction, or destroying all instances if no network |
| | is provided. |
| | Example const provider = getProvider(networkName) |
| getAptosInstance(network: NetworkNames) | To get the RPC Provider for the given network. |
| | Retrieve the Aptos SDK instance |
Available Methods in SDK
| Methods | Description | | --------------------------------------------------|--------------------------------------------------------| | getCounterFactualAddress(): Promise | To get the KanaWallet address | | signMessage(dto: SignMessageDto): Promise | To sign a message | | getNativeBalance(): Promise | To get the native token balance of the wallet | | getTokenBalance(tokenAddress: string) | To get the ERC20 token balance of the wallet | | : Promise | | | addUserOpsToBatch(tx: UserOpsRequest) | To add transactions to the batch | | : Promise | | | clearUserOpsFromBatch(): Promise | To clear the transactions in the batch | | estimate(gasDetails?: TransactionGasInfoForUserOp)| To estimate transactions added to the batch and get the| | : Promise | fee data for the UserOp | | send(userOp: UserOperationStruct): Promise| To sign the UserOp and send it to the bundler . | | Returns userOp | | createSession(dto?: CreateSessionDto) | To sign create a session | | : Promise | | | getUserOpReceipt(userOpHash: string) | To get the transaction hash | | getGasFee(): Promise | To get the Gas data | | destroy(): void | To destroy the instance |
Helpers
Available Properties in ERC20
| Properties | Description | | ----------------- | ----------------------------------------------------------------- | | name | Returns the name of the token | | symbol | Returns the symbol (ticker) of the token. | | decimals | Returns the number of decimal places that the token uses | | totalSupply | Returns the total supply of the token in its smallest units. | | balanceOf | Returns the token balance of a specific address (owner) | | allowance | Returns the amount of tokens that the spender is allowed to spend | | approve | Allows the owner to approve a spender to spend | | decreaseAllowance | Decreases the amount of tokens that a spender is allowed to spend | | increaseAllowance | Increases the amount of tokens that a spender is allowed | | transfer | Allows the sender to transfer a certain amount of tokens | | transferFrom | Allows the spender to transfer a certain amount of tokens |
Available Properties in ERC721
| Properties | Description | | ----------------- | ------------------------------------------------------------------ | | name | Returns the name of the NFT contract | | symbol | Returns the symbol (ticker) of the NFT contract | | balanceOf | Returns the number of NFTs owned by a specific address (owner). | | ownerof | Returns the address of the owner of a specific NFT identified | | getApproved | Returns the address that has been approved to take ownership | | isApprovedForAll | Returns whether a specific operator address is approved | | tokenURI | Returns the metadata URI associated with a specific NFT identified | | safeTransferFrom | Safely transfers the ownership of a specific NFT from the sender | | transferFrom | Transfers the ownership of a specific NFT | | approve | Approves another address (to) to take ownership of a specific NFT | | setApprovalForAll | Sets or revokes operator status for an address to manage all NFTs |
Available Properties in ERC1155
| Properties | Description | | --------------------- | ---------------------------------------------------------------- | | balanceOf | Returns the amount of tokens of token type id owned by account | | balanceOfBatch | Returns the balances of multiple token IDs for multiple accounts | | setApprovalForAll | Grants permission to operator to transfer tokens | | isApprovedForAll | Returns true if operator is approved to transfer tokens. | | safeTransferFrom | Safely transfers specific token type and quantity | | safeBatchTransferFrom | Safely transfers multiple token types and quantities | | uri | Returns the URI of that tokenId |
Available Properties in DATASERVICE
| Properties | Description | | --------------------- | ---------------------------------------------------------------- | | getAccountBalances | Returns the account balances for the particular address | | getTransaction | Returns the transaction history for the particular transactions | | getNftsList | Returns the nfts list for the particular address |
Available Properties in PAYMASTER
| Properties | Description | | --------------------- | -------------------------------------------------------------------------| | addWhitelist | To add a whitelist using the specified accountAddress and chain ID | | checkWhitelist | To check a whitelist using the specified accountAddress and chain ID | | depositWhitelist | To Deposit using the specified amount and chain ID | | getSponsorBalance | To get a sponsor balance using the specified sponsorAddress and chain ID |