"Bundle" entrypoint metadata to reduce number of network calls #917
Replies: 4 comments
-
The entry points are loaded inside the For example:
However, this solution may not be convivial if you are also using the tzip12 / 16 abstraction, so being able to bundle the script or entry points is a good idea. I'll think about how we can do it. |
Beta Was this translation helpful? Give feedback.
-
@AndreasGassmann The new ContractsLibrary feature allows bundling script and entry point of contracts. Here is a link to the documentation: https://tezostaquito.io/docs/contracts-library |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for including this feature. We will give it a go in youves and let you know how it works. |
Beta Was this translation helpful? Give feedback.
-
Works like a charm. Together with the caching improvements, we brought the request count from around 160 requests to below 60! Compared to before, the page is noticeably faster to load. (1.5-2s loading before, now below 1s). For anyone who wants to give this a try, a small script that fetches an array of contracts and stores it in a file: const fs = require('fs')
const { TezosToolkit } = require('@taquito/taquito')
const Tezos = new TezosToolkit('https://granadanet.smartpy.io')
const getDataForContracts = async (
obj: Record<string, { script: string; entrypoints: string }>,
contracts: string[]
) => {
for (let contract of contracts) {
const script = await Tezos.rpc.getScript(contract)
const entrypoints = await Tezos.rpc.getEntrypoints(contract)
obj[contract] = {
script,
entrypoints,
}
}
}
const object: Record<string, { script: string; entrypoints: string }> = {}
const contractAddresses: string[] = [] // Add contract addresses here
getDataForContracts(object, contractAddresses).then(() => {
console.log(object)
fs.writeFileSync(
'./contracts.ts',
`export const contractInfo = ${JSON.stringify(object)}`
)
}) |
Beta Was this translation helpful? Give feedback.
-
During every page load, the entrypoints of every contract we use are loaded. Are those entrypoints dynamic, or are they static once a contract has been deployed? If they are static, is there a way to "bundle" the entrypoint metadata in the app and provide it to taquito, so it doesn't have to do the extra requests?
Beta Was this translation helpful? Give feedback.
All reactions