@kaiachain/kaia-agent-kit
Version:
One stop solution for all Kaia Ecosystem projects
1 lines • 93.3 kB
Source Map (JSON)
{"version":3,"sources":["../src/kaia.plugin.ts","../src/packages/kaiascan/index.ts","../src/packages/kaiascan/services.ts","../src/utils/constants.ts","../src/packages/kaiascan/utils/validations.ts","../src/packages/kaiascan/src/accounts/getAccountOverview.ts","../src/packages/kaiascan/src/accounts/getCurrentBalance.ts","../src/packages/kaiascan/src/accounts/getFTBalance.ts","../src/packages/kaiascan/src/accounts/getNFTBalance.ts","../src/packages/kaiascan/src/kaiainfo/getKaiaInfo.ts","../src/packages/kaiascan/src/transactions/getBlockInfo.ts","../src/packages/kaiascan/src/transactions/getLatestBlock.ts","../src/packages/kaiascan/src/transactions/getTransactionsByAccount.ts","../src/packages/kaiascan/src/transactions/getTransactionsByBlockNumber.ts","../src/packages/kaiascan/metadata.ts","../src/packages/kaiascan/examples/getAccountOverview.ts","../src/packages/kaiascan/examples/getBlock.ts","../src/packages/kaiascan/examples/getCurrentBalance.ts","../src/packages/kaiascan/examples/getFTBalanceDetails.ts","../src/packages/kaiascan/examples/getKaiaInfo.ts","../src/packages/kaiascan/examples/getLatestBlock.ts","../src/packages/kaiascan/examples/getNFTBalance.ts","../src/packages/kaiascan/examples/getTransactionsByAccount.ts","../src/packages/kaiascan/examples/getTransactionsByBlock.ts","../src/packages/web3/index.ts","../src/packages/web3/services.ts","../src/packages/web3/utils/token.ts","../src/packages/web3/src/transferErc20.ts","../src/packages/web3/utils/helper.ts","../src/packages/web3/src/transferErc721.ts","../src/packages/web3/src/transferErc1155.ts","../src/packages/web3/src/transferNativeToken.ts","../src/packages/web3/src/transferFaucet.ts","../src/packages/web3/utils/validations.ts","../src/packages/web3/metadata.ts","../src/packages/web3/examples/faucet.ts","../src/packages/web3/examples/transfer.ts","../src/packages/dgswap/index.ts","../src/packages/dgswap/services.ts","../src/packages/dgswap/utils/gql.ts","../src/packages/dgswap/src/pool/getPoolByTokenSymbol.ts","../src/packages/dgswap/src/pool/getPoolByTokenAddress.ts","../src/packages/dgswap/src/data/getPoolDayData.ts","../src/packages/dgswap/src/data/getTokenDayData.ts","../src/packages/dgswap/metadata.ts","../src/index.ts"],"sourcesContent":["import { Chain, PluginBase, ToolBase, createTool } from \"@goat-sdk/core\";\nimport { EVMWalletClient } from \"@goat-sdk/wallet-evm\";\nimport { Packages, PackagesEnum } from \"./index\";\n\nexport class KaiaPlugin extends PluginBase<EVMWalletClient> {\n private config: Record<string, unknown>;\n\n constructor(config: Record<string, unknown> = {}) {\n super(\"kaia\", []);\n this.config = config;\n }\n\n // For EVM-specific plugin, we check if the chain is EVM compatible\n supportsChain = (chain: Chain) => {\n return chain.type === \"evm\";\n };\n\n getTools(walletClient: EVMWalletClient) {\n const tools: ToolBase[] | Promise<ToolBase[]> = [];\n const config = this.config;\n const packagesEnabled: PackagesEnum[] = (config.packages ||\n []) as PackagesEnum[];\n \n for (const [pkgName, pkg] of Object.entries(Packages)) {\n\n if (\n packagesEnabled.length > 0 &&\n !packagesEnabled.includes(pkgName as PackagesEnum)\n ) {\n continue;\n }\n\n const services =\n (pkg as { Services?: Record<string, unknown> }).Services || {};\n const metadata: any = pkg.Metadata || {};\n\n for (const [serviceName, serviceFn] of Object.entries(services)) {\n\n const meta = metadata[serviceName];\n if (meta) {\n\n const tool = {\n info: {\n name: meta.name,\n description: meta.description,\n parameters: meta.params,\n },\n handler: (parameters: unknown) =>\n (\n serviceFn as (\n params: unknown,\n config: unknown,\n client: EVMWalletClient\n ) => unknown\n )(parameters, config, walletClient),\n };\n\n tools.push(createTool(tool.info, tool.handler));\n }\n }\n }\n\n return tools;\n }\n}\n\nexport function Kaia(config: Record<string, unknown> = {}) {\n return new KaiaPlugin(config);\n}\n","export * as Services from './services';\nexport * as Metadata from './metadata';","export * from \"./src/accounts/getAccountOverview\";\nexport * from \"./src/accounts/getCurrentBalance\";\nexport * from \"./src/accounts/getFTBalance\";\nexport * from \"./src/accounts/getNFTBalance\";\n\nexport * from \"./src/kaiainfo/getKaiaInfo\";\n\nexport * from \"./src/transactions/getBlockInfo\";\nexport * from \"./src/transactions/getLatestBlock\";\nexport * from \"./src/transactions/getTransactionsByAccount\";\nexport * from \"./src/transactions/getTransactionsByBlockNumber\";","export const API_DEFAULTS: any = {\n BASE_URL: {\n \"kairos\": \"https://kairos-oapi.kaiascan.io/api/v1\",\n \"kaia\": \"https://mainnet-oapi.kaiascan.io/api/v1\",\n }\n};","import { isAddress } from \"viem\";\n\nlet validations: any = {};\n\nvalidations.checkApiKey = (apiKey: any) => {\n if (!apiKey) {\n throw new Error(\"Missing API key\");\n }\n};\n\nvalidations.checkAddress = (address: any) => {\n return isAddress(address);\n};\n\nvalidations.checkNetwork = (network: any) => {\n if (network !== \"kairos\" && network !== \"kaia\") {\n throw new Error(\"Invalid network\");\n }\n};\n\nexport default validations;\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getAccountOverview = async (parameters: any, config: any) => {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n let { address, network } = parameters;\n network = network ? network.toLowerCase() : \"kairos\";\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n validations.checkAddress(address);\n validations.checkNetwork(network);\n\n const url = `${API_DEFAULTS.BASE_URL[network]}/accounts/${address}`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n let responseText = `Here are the details \\nAccount Details:\\n`;\n responseText += `Address: ${data.address}\\n`;\n responseText += `Account Type: ${data.account_type}\\n`;\n responseText += `Balance: ${data.balance}\\n`;\n responseText += `Total Transaction Count: ${data.total_transaction_count}\\n`;\n\n return responseText;\n};\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getCurrentBalance = async (parameters: any, config: any) => {\n try {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n let { address, network } = parameters;\n network = network ? network.toLowerCase() : \"kairos\";\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n validations.checkAddress(address);\n validations.checkNetwork(network);\n\n const url = `${API_DEFAULTS.BASE_URL[network]}/accounts/${address}`;\n\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n let responseText = `The current balance of ${address} is ${\n data.balance\n } KAIA on ${String(network)} network`;\n\n return responseText;\n } catch (error: any) {\n return `Failed to fetch current balance : ${error.message}`;\n }\n};\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getFTBalance = async (parameters: any, config: any) => {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n let { address, network } = parameters;\n network = network ? network.toLowerCase() : \"kairos\";\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n validations.checkAddress(address);\n validations.checkNetwork(network);\n\n const url = `${API_DEFAULTS.BASE_URL[network]}/accounts/${address}/token-details`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n const totalCount = data.paging.total_count;\n let responseText: string = `Your account has ${totalCount} FTs. They are as follows:\\n`;\n\n data.results.forEach((item: any, index: number) => {\n responseText += `${index + 1}. Contract address = ${\n item.contract.contract_address\n } | symbol = ${item.contract.symbol} | name = ${\n item.contract.name\n } | total supply = ${item.contract.total_supply} | balance = ${\n item.balance\n }\\n`;\n });\n\n return responseText;\n};\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getNFTBalance = async (parameters: any, config: any) => {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n let { address, network } = parameters;\n network = network ? network.toLowerCase() : \"kairos\";\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n validations.checkAddress(address);\n validations.checkNetwork(network);\n\n const url = `${API_DEFAULTS.BASE_URL[network]}/accounts/${address}/nft-balances/kip17`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n const totalCount = data.paging.total_count;\n let responseText = `Your account has ${totalCount} NFT Collections. They are as follows:\\n`;\n\n data.results.forEach((item: any, index: number) => {\n responseText += `${index + 1}. Contract address - ${\n item.contract.contract_address\n } | Token count - ${item.token_count}\\n`;\n });\n\n return responseText;\n};\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getKaiaInfo = async (parameters: any, config: any) => {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n\n const url = `${API_DEFAULTS.BASE_URL[\"kaia\"]}/kaia`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n let responseText = `Kaia Token Info:\\n`;\n responseText += `- USD Price: ${data.klay_price.usd_price}\\n`;\n responseText += `- BTC Price: ${data.klay_price.btc_price}\\n`;\n responseText += `- USD Price Changes: ${data.klay_price.usd_price_changes}\\n`;\n responseText += `- Market Cap: ${data.klay_price.market_cap}\\n`;\n responseText += `- Total Supply: ${data.klay_price.total_supply}\\n`;\n responseText += `- Volume: ${data.klay_price.volume}\\n`;\n\n return responseText;\n};\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getBlockInfo = async (parameters: any, config: any) => {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n let { blockNumber, network } = parameters;\n network = network ? network.toLowerCase() : \"kairos\";\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n validations.checkNetwork(network);\n\n const url = `${API_DEFAULTS.BASE_URL[network]}/blocks/${blockNumber}`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n let blockInfo = `Block Number: ${data.block_id}\\n`;\n blockInfo += `Block Time: ${data.datetime}\\n`;\n blockInfo += `Block Hash: ${data.hash}\\n`;\n blockInfo += `Total Transaction Count: ${data.total_transaction_count}`;\n\n let responseText = `The block info for ${blockNumber} on ${network} is ${blockInfo}`;\n return responseText;\n};\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getLatestBlock = async (parameters: any, config: any) => {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n let { network } = parameters;\n network = network ? network.toLowerCase() : \"kairos\";\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n validations.checkNetwork(network);\n\n const url = `${API_DEFAULTS.BASE_URL[network]}/blocks/latest`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n let responseText = `The latest block number of ${network} is ${data.block_id}`;\n return responseText;\n};\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getTransactionsByAccount = async (\n parameters: any,\n config: any\n) => {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n let { address, network } = parameters;\n network = network ? network.toLowerCase() : \"kairos\";\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n validations.checkAddress(address);\n validations.checkNetwork(network);\n\n const url = `${API_DEFAULTS.BASE_URL[network]}/accounts/${address}/transactions`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n let accountTransactions = \"\";\n if (data && data.results.length > 0) {\n data.results.map((transaction: any, index: number) => {\n if (index > 5) return;\n accountTransactions += ` ----------------------------------- \\n`;\n accountTransactions += `${index + 1}:\\n`;\n accountTransactions += `from: ${transaction.from},\\n`;\n accountTransactions += `to: ${transaction.to}, \\n`;\n accountTransactions += `value: ${transaction.amount}, \\n`;\n accountTransactions += `type: ${transaction.transaction_type}, \\n`;\n accountTransactions += `hash: ${transaction.transaction_hash}\\n`;\n });\n } else {\n accountTransactions = \"No transactions found for this address\";\n }\n\n let responseText = `The transactions for ${address} account on ${network} is ${accountTransactions}`;\n return responseText;\n};\n","import { API_DEFAULTS } from \"../../../../utils/constants\";\nimport validations from \"../../utils/validations\";\n\nexport const getTransactionsByBlockNumber = async (\n parameters: any,\n config: any\n) => {\n let KAIA_KAIASCAN_API_KEY = config.KAIA_KAIASCAN_API_KEY;\n let { blockNumber, network } = parameters;\n network = network ? network.toLowerCase() : \"kairos\";\n\n validations.checkApiKey(KAIA_KAIASCAN_API_KEY);\n validations.checkNetwork(network);\n\n const url = `${API_DEFAULTS.BASE_URL[network]}/transactions?blockNumberStart=${blockNumber}&blockNumberEnd=${blockNumber}`;\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Accept: \"*/*\",\n Authorization: `Bearer ${KAIA_KAIASCAN_API_KEY}`,\n },\n });\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error?.message || response.statusText);\n }\n\n const data = await response.json();\n\n let blockTransactions = \"\";\n if (data && data.results.length > 0) {\n data.results.map((transaction: any, index: any) => {\n if (index > 5) return;\n blockTransactions += ` ----------------------------------- \\n`;\n blockTransactions += `${index + 1}:\\n`;\n blockTransactions += `from: ${transaction.from},\\n`;\n blockTransactions += `to: ${transaction.to}, \\n`;\n blockTransactions += `value: ${transaction.amount}, \\n`;\n blockTransactions += `type: ${transaction.transaction_type}, \\n`;\n blockTransactions += `hash: ${transaction.transaction_hash}\\n`;\n });\n } else {\n blockTransactions = \"No transactions found for this block\";\n }\n\n let responseText = `The transactions in a block for ${blockNumber} on ${network} is ${blockTransactions}`;\n return responseText;\n};\n","import {z} from 'zod';\n\nimport { getAccountOverviewExamples } from \"./examples/getAccountOverview\";\nimport { getBlockExamples } from \"./examples/getBlock\";\nimport { getCurrentBalanceExamples } from \"./examples/getCurrentBalance\";\nimport { getFTBalanceDetailsExamples } from \"./examples/getFTBalanceDetails\";\nimport { getKaiaInfoExamples } from \"./examples/getKaiaInfo\";\nimport { getLatestBlockExamples } from \"./examples/getLatestBlock\";\nimport { getNFTBalanceExamples } from \"./examples/getNFTBalance\";\nimport { getTransactionsByAccountExamples } from \"./examples/getTransactionsByAccount\";\nimport { getTransactionsByBlockExamples } from \"./examples/getTransactionsByBlock\";\n\n/* Function names are same as the function names in the services.ts file */\n\nexport const getAccountOverview = {\n name: 'get_account_overview',\n description: 'Get the Account Overview for a given address and network (kaia or kairos)',\n params: z.object({\n address: z.string(),\n network: z.string()\n }),\n similes: [\"get_account_overview\"],\n validate: async () => true,\n examples: getAccountOverviewExamples\n}\n\nexport const getCurrentBalance = {\n name: 'get_current_balance',\n description: 'Get the current balance for a given address and network (kaia or kairos)',\n params: z.object({\n address: z.string(),\n network: z.string()\n }),\n similes: [\"get_current_balance\"],\n validate: async () => true,\n examples: getCurrentBalanceExamples,\n}\n\nexport const getFTBalance = {\n name: 'get_ft_balance',\n description: 'Get the Fungible token or ft or erc20 or kip 7 balances for a given address and network',\n params: z.object({\n address: z.string(),\n network: z.string()\n }),\n similes: [\"get_ft_balance\"],\n validate: async () => true,\n examples: getFTBalanceDetailsExamples,\n}\n\nexport const getNFTBalance = {\n name: 'get_nft_balance_details',\n description: 'Get the Non-Fungible token or nft or erc721 or kip17 balances for a given address and network (kaia or kairos)',\n params: z.object({\n address: z.string(),\n network: z.string()\n }),\n similes: [\"get_nft_balance_details\"],\n validate: async () => true,\n examples: getNFTBalanceExamples,\n}\n\nexport const getKaiaInfo = {\n name: 'get_kaia_info',\n description: 'Get the kaia current info or kaia overview about Kaia Token or gets current kaia price',\n params: z.object({}),\n similes: [\"get_kaia_info\"],\n validate: async () => true,\n examples: getKaiaInfoExamples,\n}\n\nexport const getBlockInfo = {\n name: 'get_block_info',\n description: 'Get the block info for a given block number and network (kaia or kairos)',\n params: z.object({\n blockNumber: z.number(),\n network: z.string()\n }),\n similes: [\"get_block_info\"],\n validate: async () => true,\n examples: getBlockExamples,\n}\n\nexport const getLatestBlock = {\n name: 'get_latest_block',\n description: 'Get the latest block number or block height for a given network (kaia or kairos)',\n params: z.object({\n network: z.string()\n }),\n similes: [\"get_latest_block\"],\n validate: async () => true,\n examples: getLatestBlockExamples,\n}\n\nexport const getTransactionsByAccount = {\n name: 'get_transactions_by_account',\n description: 'Get the transactions for given address and network (kaia or kairos)',\n params: z.object({\n address: z.string(),\n network: z.string()\n }),\n similes: [\"get_transactions_by_account\"],\n validate: async () => true,\n examples: getTransactionsByAccountExamples,\n}\n\nexport const getTransactionsByBlockNumber = {\n name: 'get_transactions_by_block_number',\n description: 'Get the transactions for given block number and network (kaia or kairos)',\n params: z.object({\n blockNumber: z.number(),\n network: z.string()\n }),\n similes: [\"get_transactions_by_block_number\"],\n validate: async () => true,\n examples: getTransactionsByBlockExamples,\n}","export const getAccountOverviewExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Tell me about my account.\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Which account address would you like to check? Also, please provide the network.\",\n },\n },\n {\n user: \"{{user1}}\",\n content: {\n text: \"0x840e00ffc46734c3ac97b0e88b1589f83b3874ec\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Noted, since you didn't provide the network, I'll assume it's kaia mainnet. Let me fetch the details for 0x840e00ffc46734c3ac97b0e88b1589f83b3874ec.\",\n action: \"get_account_overview\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Can you give me an overview of my account?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Sure, which account address would you like to check?\",\n },\n },\n {\n user: \"{{user1}}\",\n content: {\n text: \"0x840e00ffc46734c3ac97b0e88b1589f83b3874ec\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me fetch the details for 0x840e00ffc46734c3ac97b0e88b1589f83b3874ec on kaia mainnet.\",\n action: \"get_account_overview\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the overview of 0x840e00ffc46734c3ac97b0e88b1589f83b3874ec on kairos?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll get the account details for 0x840e00ffc46734c3ac97b0e88b1589f83b3874ec on kairos network.\",\n action: \"get_account_overview\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Can you show me the details of my portfolio?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Which account address would you like to check?\",\n },\n },\n {\n user: \"{{user1}}\",\n content: {\n text: \"0x840e00ffc46734c3ac97b0e88b1589f83b3874ec on kairos network.\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Fetching the portfolio details for 0x840e00ffc46734c3ac97b0e88b1589f83b3874ec on kairos network.\",\n action: \"get_account_overview\",\n },\n }\n ],\n];","export const getBlockExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's is the block info of 12345 like right now?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"In which network?\",\n },\n },\n {\n user: \"{{user1}}\",\n content: {\n text: \"kairos\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me check the latest block info in kairos for you.\",\n action: \"GET_BLOCK\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"It's Block Number: 1234 \\n Block Time: 10/10/2025 \\n Block Hash: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e \\n Block Size: 123. Please explore kaia ecosystem.\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the block info for 12345 on kaia?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the block info for 12345 in kaia for you.\",\n action: \"GET_BLOCK\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"It's Block Number: 1234 \\n Block Time: 10/10/2025 \\n Block Hash: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e \\n Block Size: 123. and can explore kaia minidapps.\",\n },\n },\n ]\n];\n","export const getCurrentBalanceExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the kaia balance like right now?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"In which address?\",\n },\n },\n {\n user: \"{{user1}}\",\n content: {\n text: \"0x4d69770905f43c07d4085dfd296a03484d05280f\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me check the current balance in 0x4d69770905f43c07d4085dfd296a03484d05280f for you.\",\n action: \"GET_CURRENT_BALANCE\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the balance of 0x4d69770905f43c07d4085dfd296a03484d05280f?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the current balance in 0x4d69770905f43c07d4085dfd296a03484d05280f for you.\",\n action: \"GET_CURRENT_BALANCE\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Is there any funds in 0x4d69770905f43c07d4085dfd296a03484d05280f?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the current balance in 0x4d69770905f43c07d4085dfd296a03484d05280f.\",\n action: \"GET_CURRENT_BALANCE\",\n },\n }\n ],\n];\n","export const getFTBalanceDetailsExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the fungible token balance of 0x4d69770905f43c07d4085dfd296a03484d05280f?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the fungible token balance in 0x4d69770905f43c07d4085dfd296a03484d05280f for you.\",\n action: \"GET_FT_BALANCE_DETAILS\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"How many FT tokens are in 0x4d69770905f43c07d4085dfd296a03484d05280f?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me see how many FT tokens are in 0x4d69770905f43c07d4085dfd296a03484d05280f.\",\n action: \"GET_FT_BALANCE_DETAILS\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the balance of 0x4d69770905f43c07d4085dfd296a03484d05280f on kaia mainnet?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the fungible token balance in 0x4d69770905f43c07d4085dfd296a03484d05280f on kaia mainnet for you.\",\n action: \"GET_FT_BALANCE_DETAILS\",\n },\n }\n ]\n];","export const getKaiaInfoExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Can you give me overview of kaia?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Sure, let me fetch the Kaia details for you.\",\n action: \"GET_KAIA_INFO\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Can you tell me the Kaia price details?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Sure, let me fetch the Kaia price details for you.\",\n action: \"GET_KAIA_INFO\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the current market cap of Kaia?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me check the current market cap of Kaia for you.\",\n action: \"GET_KAIA_INFO\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"How much is the total supply of Kaia?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the total supply of Kaia for you.\",\n action: \"GET_KAIA_INFO\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Can you provide the volume of Kaia?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me fetch the volume of Kaia for you.\",\n action: \"GET_KAIA_INFO\",\n },\n },\n ],\n];\n","export const getLatestBlockExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's is the latest block number like right now?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"In which network?\",\n action: \"NONE\",\n },\n },\n {\n user: \"{{user1}}\",\n content: {\n text: \"kairos\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me check the latest block number in kairos for you.\",\n action: \"GET_LATEST_BLOCK\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"It's currently 1000000 block height. You can check the latest block number in kaia as well.\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the latest block number of kaia?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the current block height in kaia for you.\",\n action: \"GET_LATEST_BLOCK\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"It's currently 10000000 block height and can explore kaia minidapps.\",\n },\n },\n ]\n];\n","export const getNFTBalanceExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the NFT balance of 0x4d69770905f43c07d4085dfd296a03484d05280f?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the NFT balance in 0x4d69770905f43c07d4085dfd296a03484d05280f for you.\",\n action: \"GET_NFT_BALANCE\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Which NFTs are in 0x1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me see which NFTs are in 0x1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t.\",\n action: \"GET_NFT_BALANCE\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the balance of 0x5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4 on kaia mainnet?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the NFT balance in 0x5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4 on kaia mainnet for you.\",\n action: \"GET_NFT_BALANCE\",\n },\n }\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the non fungible tokens balance of 0x9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8 on kaia mainnet?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the non fungible tokens balance in 0x9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7a8 on kaia mainnet for you.\",\n action: \"GET_NFT_BALANCE\",\n },\n }\n ],\n \n];","export const getTransactionsByAccountExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's are the transactions for address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e like right now?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"In which network?\",\n },\n },\n {\n user: \"{{user1}}\",\n content: {\n text: \"kairos\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me check the transactions for address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e in kairos for you.\",\n action: \"GET_TRANSACTIONS_BY_ACCOUNT\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"It's Block Number: 1234 \\n Block Time: 10/10/2025 \\n Block Hash: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e \\n Block Size: 123. Please explore kaia ecosystem.\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the list of transactions for address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e on kaia?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e for transactions in kaia for you.\",\n action: \"GET_BLOCK\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"It's Block Number: 1234 \\n Block Time: 10/10/2025 \\n Block Hash: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e \\n Block Size: 123. and can explore kaia minidapps.\",\n },\n },\n ]\n];\n","export const getTransactionsByBlockExamples = [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's are the transactions in block 12345 like right now?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"In which network?\",\n },\n },\n {\n user: \"{{user1}}\",\n content: {\n text: \"kairos\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"Let me check the transactions in block 12345 in kairos for you.\",\n action: \"GET_BLOCK\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"It's Block Number: 1234 \\n Block Time: 10/10/2025 \\n Block Hash: 0x23kdhjsfsdkhfkjhkjhdf \\n Block Size: 123. Please explore kaia ecosystem.\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What's the list of transactions in block for 12345 on kaia?\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"I'll check the block 12345 for transactions in kaia for you.\",\n action: \"GET_BLOCK\",\n },\n },\n {\n user: \"{{agent}}\",\n content: {\n text: \"It's Block Number: 1234 \\n Block Time: 10/10/2025 \\n Block Hash: 0x23kdhjsfsdkhfkjhkjhdf \\n Block Size: 123. and can explore kaia minidapps.\",\n },\n },\n ]\n];\n","export * as Services from './services';\nexport * as Metadata from './metadata';","\r\nexport * from './src/transferErc20';\r\nexport * from './src/transferErc721';\r\nexport * from './src/transferErc1155';\r\nexport * from './src/transferNativeToken';\r\nexport * from './src/transferFaucet';","import assert from \"assert\";\nimport { encodeFunctionData, EncodeFunctionDataParameters } from \"viem\";\n\nexport type TokenTransferPayload = {\n sender: `0x${string}`;\n type: \"erc20\" | \"erc721\" | \"erc1155\";\n receiver: `0x${string}`;\n amount: string | bigint | number; // Optional, only needed for erc20 and erc1155\n tokenId: string; // Optional, only needed for erc721 and erc1155\n contractAddress: string;\n};\n\nexport type FaucetTransferPayload = {\n receiver: `0x${string}`;\n};\n\nexport class AbiFactory {\n constructor(private params: Partial<TokenTransferPayload>) {}\n\n private getErc20Params() {\n const abi = [\n {\n constant: false,\n inputs: [\n {\n name: \"_to\",\n type: \"address\",\n },\n {\n name: \"_value\",\n type: \"uint256\",\n },\n ],\n name: \"transfer\",\n outputs: [\n {\n name: \"\",\n type: \"bool\",\n },\n ],\n type: \"function\",\n },\n ];\n assert(\n this.params.receiver && this.params.amount,\n \"invalid params for transfer erc20\"\n );\n\n const args = [this.params.receiver, this.params.amount];\n const functionName = \"transfer\";\n return { abi, args, functionName };\n }\n\n private getErc721Params() {\n const abi = [\n {\n constant: false,\n inputs: [\n {\"name\":\"from\",\"type\":\"address\"},\n {\n name: \"_to\",\n type: \"address\",\n },\n {\n name: \"_tokenId\",\n type: \"uint256\",\n },\n ],\n name: \"transferFrom\",\n outputs: [],\n type: \"function\",\n },\n ];\n assert(\n this.params.sender && this.params.receiver && this.params.tokenId,\n \"invalid params for transfer erc721\"\n );\n const args = [\n this.params.sender,\n this.params.receiver,\n this.params.tokenId,\n ];\n const functionName = \"transferFrom\";\n return { abi, args, functionName };\n }\n\n private getErc1155Params() {\n const abi = [\n {\n constant: false,\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n },\n {\n name: \"id\",\n type: \"uint256\",\n },\n {\n name: \"amount\",\n type: \"uint256\",\n },\n {\n name: \"data\",\n type: \"bytes\",\n },\n ],\n name: \"safeTransferFrom\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n ];\n assert(\n this.params.sender &&\n this.params.receiver &&\n this.params.tokenId &&\n this.params.amount,\n \"invalid params for transfer erc1155\"\n );\n const args = [\n this.params.sender,\n this.params.receiver,\n this.params.tokenId,\n this.params.amount,\n \"\",\n ];\n const functionName = \"safeTransferFrom\";\n return { abi, args, functionName };\n }\n\n public createParams(): string {\n let params: { abi: any; args: any[]; functionName: string };\n switch (this.params.type) {\n case \"erc20\":\n params = this.getErc20Params();\n break;\n case \"erc721\":\n params = this.getErc721Params();\n break;\n case \"erc1155\":\n params = this.getErc1155Params();\n break;\n default:\n throw new Error(\"Unsupported token type\");\n }\n // encode data\n const { abi, args, functionName } = params;\n\n return encodeFunctionData({\n abi,\n functionName,\n args,\n } as EncodeFunctionDataParameters);\n }\n}\n","import { AbiFactory, TokenTransferPayload } from \"../utils/token\";\nimport { isKlaytnAccountKeyType, TxType } from \"@kaiachain/ethers-ext\";\nimport { keccak256 } from \"viem\";\nimport { getAccount } from \"../utils/helper\";\n\nasync function getContractDecimals(contractAddress: string, walletClient: any) {\n\n try {\n if (walletClient.call) {\n // Step 1: Get the Keccak-256 hash of the function signature\n const functionSignature = new TextEncoder().encode(\"decimals()\");\n const functionHash = keccak256(functionSignature);\n\n // Step 2: First 4 bytes (8 hex chars) → function selector\n const selector = functionHash.slice(0, 10); // '0x' + 8 char\n const result = await walletClient.call({\n to: contractAddress,\n data: selector,\n });\n\n const decimals = parseInt(result, 16);\n\n return decimals;\n } else if (walletClient.read) {\n\n const result = await walletClient.read({\n address: contractAddress,\n abi: [\n {\n constant: true,\n inputs: [],\n name: \"decimals\",\n outputs: [\n {\n name: \"\",\n type: \"uint8\",\n },\n ],\n payable: false,\n stateMutability: \"view\",\n type: \"function\",\n },\n ],\n functionName: \"decimals\",\n args: [],\n });\n \n return result?.value || 18;\n } else {\n throw new Error(\"Problem calculating the decimals\");\n }\n } catch (err) {\n console.error(\"Error fetching decimals:\", err);\n throw err;\n }\n}\n\nexport const transferErc20 = async (\n parameters: Omit<TokenTransferPayload, \"type\" | \"tokenId\">,\n config: any,\n walletClient: any\n) => {\n try {\n const sender =\n walletClient.address ||\n walletClient.account?.address ||\n walletClient.getAddress();\n const accountType: { accType: number } = await await getAccount(\n walletClient,\n sender\n );\n parameters.sender = sender;\n parameters.amount = await getContractDecimals(\n parameters.contractAddress,\n walletClient\n );\n\n const res: any = {\n from: sender,\n to: parameters.contractAddress,\n data: new AbiFactory({\n ...(parameters as Partial<TokenTransferPayload>),\n type: \"erc20\",\n }).createParams(),\n type: undefined,\n };\n if (\n walletClient.provider?.kaia &&\n isKlaytnAccountKeyType(accountType.accType)\n ) {\n res.type = TxType.SmartContractExecution;\n }\n\n const sentTx = await walletClient.sendTransaction(res);\n return {\n transactionHash: sentTx.hash || sentTx,\n };\n } catch (err) {\n console.log(err);\n throw err;\n }\n};\n","export async function getAccount(walletClient: any, sender: string) {\n // Ethers-ext\n if(walletClient.provider) {\n walletClient = walletClient.provider;\n }\n \n // Viem\n if(walletClient.send) {\n return await walletClient.send(\"kaia_getAccount\", [sender, \"latest\"]);\n } else if(walletClient.request) {\n return await walletClient.request({\n method: \"kaia_getAccount\",\n params: [sender, \"latest\"],\n });\n }\n \n}","import { isKlaytnAccountKeyType, TxType } from \"@kaiachain/ethers-ext\";\nimport { AbiFactory, TokenTransferPayload } from \"../utils/token\";\nimport { getAccount } from \"../utils/helper\";\n\nexport const transferErc721 = async (\n parameters: Omit<TokenTransferPayload, \"type\" | \"amount\">,\n config: any,\n walletClient: any\n) => {\n try {\n const sender =\n walletClient.address ||\n walletClient.account?.address ||\n walletClient.getAddress();\n const accountType: { accType: number } = await await getAccount(\n walletClient,\n sender\n );\n parameters.sender = sender;\n const res: any = {\n from: sender,\n to: parameters.contractAddress,\n data: new AbiFactory({\n ...(parameters as Partial<TokenTransferPayload>),\n type: \"erc721\",\n }).createParams(),\n type: undefined,\n };\n if (\n walletClient.provider?.kaia && isKlaytnAccountKeyType(accountType.accType)\n ) {\n res.type = TxType.SmartContractExecution;\n }\n\n const sentTx = await walletClient.sendTransaction(res);\n return {\n transactionHash: sentTx.hash || sentTx,\n };\n } catch (err) {\n console.log(err);\n throw err;\n }\n};\n","import { isKlaytnAccountKeyType, TxType } from \"@kaiachain/ethers-ext\";\nimport { AbiFactory, TokenTransferPayload } from \"../utils/token\";\nimport { getAccount } from \"../utils/helper\";\n\nexport const transferErc1155 = async (\n parameters: Omit<TokenTransferPayload, \"type\">,\n config: any,\n walletClient: any\n) => {\n try {\n const sender =\n walletClient.address ||\n walletClient.account?.address ||\n walletClient.getAddress();\n const accountType: { accType: number } = await await getAccount(\n walletClient,\n sender\n );\n parameters.sender = sender;\n const res: any = {\n from: parameters.sender,\n to: parameters.contractAddress,\n data: new AbiFactory({\n ...(parameters as Partial<TokenTransferPayload>),\n type: \"erc1155\",\n }).createParams(),\n type: undefined,\n };\n if (\n walletClient.provider?.kaia && isKlaytnAccountKeyType(accountType.accType)\n ) {\n res.type = TxType.SmartContractExecution;\n }\n\n const sentTx = await walletClient.sendTransaction(res);\n\n return {\n transactionHash: sentTx.hash || sentTx,\n };\n } catch (err) {\n console.log(err);\n throw err;\n }\n};\n","import { isKlaytnAccountKeyType, TxType } from \"@kaiachain/ethers-ext\";\r\nimport { TokenTransferPayload } from \"../utils/token\";\r\nimport { parseEther } from \"viem\";\r\nimport { getAccount } from \"../utils/helper\";\r\n\r\nexport const transferNativeToken = async (\r\n parameters: Omit<\r\n TokenTransferPayload,\r\n \"type\" | \"tokenId\" | \"contractAddress\"\r\n >,\r\n config: any,\r\n walletClient: any\r\n) => {\r\n try {\r\n const sender =\r\n walletClient.address ||\r\n walletClient.account?.address ||\r\n walletClient.getAddress();\r\n const accountType: { accType: number } = await await getAccount(\r\n walletClient,\r\n sender\r\n );\r\n parameters.sender = sender;\r\n const res: any = {\r\n from: parameters.sender,\r\n to: parameters.receiver,\r\n value: parseEther(parameters.amount.toString()),\r\n ty