A TypeScript library that provides a convenient interface for interacting with the Kaiascan API. This SDK allows you to fetch various blockchain data, including token information, NFT details, contract creation code, and more.
- Fetch fungible token information by contract address
- Fetch NFT item details by contract address and token ID
- Get contract creation code by contract address
- Retrieve blockchain data:
- Latest block
- Specific block by number
- All blocks
- Block transactions
- Check transaction receipt status
- Fetch transaction details by hash
- Retrieve contract source code
npm install kaiascan-sdk
import { KaiascanSDK } from 'kaiascan-sdk';
const sdk = new KaiascanSDK();
const tokenAddress = '0x...';
sdk.getFungibleToken(tokenAddress)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
The response data includes:
contractType
: Contract type (e.g., "ERC20")name
: Token namesymbol
: Token symbolicon
: Token icon URLdecimal
: Token decimal placestotalSupply
: Total token supplytotalTransfers
: Total number of transfersofficialSite
: Official website URLburnAmount
: Total amount of burned tokenstotalBurns
: Total number of token burns
const nftAddress = '0x...';
const tokenId = '1234';
sdk.getNftItem(nftAddress, tokenId)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
All methods return Promise<ApiResponse<T>>
, where T
is the type of the returned data.
getFungibleToken(tokenAddress: Address)
: Get fungible token informationgetNftItem(nftAddress: Address, tokenId: string)
: Get NFT item details
getLatestBlock()
: Get the latest blockgetBlock(blockNumber: number)
: Get block by numbergetBlocks()
: Get all blocksgetTransactionsOfBlock(blockNumber: number)
: Get block transactions
getTransactionReceiptStatus(transactionHash: string)
: Check transaction receipt statusgetTransaction(transactionHash: string)
: Get transaction details
getContractCreationCode(contractAddress: Address)
: Get contract creation codegetContractSourceCode(contractAddress: Address)
: Get contract source code
The SDK throws errors for both HTTP and API-specific errors:
sdk.getFungibleToken(tokenAddress)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
Error types:
- HTTP errors:
"HTTP error! status: [status_code]"
- API errors:
"API error! code: [code], message: [message]"