0.1.6-beta-1 • Published 2 years ago
@kanalabs/mirai v0.1.6-beta-1
Mirai
Mirai - Account Abstraction SDK (EVM + non-EVM)
Installation
npm i @kanalabs/mirai
Supported Networks
Mainnets:
- AptosMainnet
- Arbitrum
- Avalanche
- Base
- Bifrost
- Bsc
- Chiado
- Flare
- Fuji
- Fuse
- Gnosis
- Klaytn
- Linea
- Mainnet
- Mantle
- Optimism
- Polygon
- ScrollTestnets:
- AptosTestnet
- ArbitrumGoerli
- BaseGoerli
- BifrostTestnet
- BscTestnet
- FlareTestnet
- FuseSparknet
- Goerli
- KlaytnTestnet
- KromaTestnet
- LineaTestnet
- Mumbai
- OptimismGoerli
- RSKTestnet
- Sepolia
- ScrollSepolia
- VerseTestnetAvailable 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. Returns KanaWallet address Note Pass network to initialize the SDK instance of a particular network Ex: initialize("mumbai") call without parameters to initialize the SDK instances for all available networks at once Ex: initialize() |
| getNativeBalance(network?: NetworkNames) | To get the native token balance of the smart wallet. Returns native token balance Note Pass network to get balance for one particular network Ex: getNativeBalance("mumbai") call without parameters to get native tokrn balance of all available networks at once Ex: getNativeBalance() |
| destroy(network?: NetworkNames) | To destroy the SDK instance. Note Pass network to destroy the SDK instance of a particular network Ex: destroy("mumbai") call without parameters to destroy the SDK instances for all available networks at once Ex: destroy() |
| setCurrentInstance(network: NetworkNames) | To set the default SDK instance. Returns the SDK instance of the given network Example setCurrentInstance(NetworkNames.Mumbai) This will return the SDK instance of mumbai and you can use seleted methods without passing the network parameter and they will work as usual |
| erc20(tokenAddress: string, network?: NetworkNames) | To get the ERC20 token instance for building ERC20 transactions. Returns the ERC20 contract instance Note Pass network parameter with token address if the token is in defferent network than the current default network pass only the token address if both token network and current default network are same Ex: const erc20 = sdk.erc20('0xb33EaAd8d922B1083446DC23f610c2567fB5180f', NetworkNames.Polygon) |
| erc721(collectionAddress: string, network?: NetworkNames) | To get the ERC721 collection instance for building ERC721 transactions. Returns the ERC721 contract instance Note Pass network parameter with collection address if the collection is in defferent network than the current default network pass only the collection address if both collection network and current default network are same Ex: const erc721 = sdk.erc721('0x7EAc1dE03B5d12ce6F1799b9FA9795393D256f12', NetworkNames.Mumbai) |
| isNetworkActive(networkName: string): boolean | To check if the given network is available and active. Returns bool Example const isActive = isNetworkActive(networkName) |
| getProvider(network: NetworkNames): providers.JsonRpcProvider | To get the Rpc Provider for the given network. Returns providers.JsonRpcProvider Example const isActive = isNetworkActive(networkName) |
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): Promise; | To get the ERC20 token balance of the wallet |
| addUserOpsToBatch(tx: UserOpsRequest): Promise; | To add transactions to the batch |
| clearUserOpsFromBatch(): Promise; | To clear the transactions in the batch |
| estimate(gasDetails?: TransactionGasInfoForUserOp): Promise; | To estimate transactions added to the batch and get the fee data for the UserOp. Returns UserOperationStruct |
| send(userOp: UserOperationStruct): Promise; | To sign the UserOp and send it to the bundler. Returns userOp hash |
| createSession(dto?: CreateSessionDto): Promise; | To sign create a session |
| 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 |
0.2.8
2 years ago
0.2.7
2 years ago
0.2.5
2 years ago
0.2.4
2 years ago
0.2.3
2 years ago
0.2.2
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago
0.1.10
2 years ago
0.1.8
2 years ago
0.1.9
2 years ago
0.1.7
2 years ago
0.1.6-beta-2
2 years ago
0.1.6-beta-1
2 years ago
0.1.6-beta
2 years ago
0.1.5
2 years ago
0.1.4
2 years ago
0.1.2
2 years ago
0.1.3
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.0.10
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago