跳到主要内容
ArcBlock Community

Best way to fetch JSON from DID Space in Pages Kit

Twelve
支持
did-spacesdocsfeature

Hello Team,

I’ve got a question about DID Space.

I want to use it to hold a priceTable.json file for my store, so my React component can pull live prices without redeploying.

👉 What’s the recommended way to fetch JSON from DID Space inside a Pages Kit component?

  • If the file is public, can I just fetch('https://{did}.abtwallet.io/files/priceTable.json') like a normal URL?
  • If it’s private, what’s the best practice for authenticating a fetch request from the front end?
  • Do you suggest using raw JSON files in DID Space, or is there a better pattern (like DID docs) for storing this kind of structured catalog data?

Just trying to set this up clean and scalable so I can manage product catalogs directly from DID Space.

Thanks 🙏

5 条回复

JianChao11个月前

你好,是每个用户都需要有自己的 priceTable.json,还是整个应用都使用同一个 priceTable.json 呢? 为什么要在 pages kit 组件中获取呢?

Twelve11个月前

Hi, I just wanted to confirm — in the Pages Kit environment, can a component directly access a user’s DID Space, or does it have to go through the server (Blocklet API) to read and write files like priceTable.json?

Connecting to DID space through the pages kit will be very helpful for some of the custom components im working on.

JianChao11个月前(edited)

是的,目前无法支持在 pages kit 组件上直接访问 did spaces。只能通过你的应用的后端接入 @blocklet/did-space-js 在后端读写 priceTable.json,然后再使用 pages kit 组件请求你的应用的 api 来完成。see: https://www.arcblock.io/docs/did-space-js/en

Twelve11个月前

Hello Jian and team,

We’ve built a complete invoicing system in Pages Kit that can dynamically calculate line items, tax, discounts, and tips. Printing and invoice management work perfectly — the only limitation now is that Payment Kit only supports static price IDs for generating payment links.

We’ve noticed that Payment Kit’s cart checkout already creates a temporary checkout session when multiple hard-priced items are sent. That’s very close to what we need — the missing piece is allowing that same flow to accept dynamic modifiers like tax_rate, discount, and tip.

Here’s what an ideal API call might look like directly from Pages Kit:

javascriptCopy
const paymentLink = await arcblock.payment.createCheckout({
  did: user.did,
  currency: 'usd',
  items: [
    { name: 'Mixing Session', amount: 20000 },
    { name: 'Mastering', amount: 10000 }
  ],
  tax_rate: 0.07,     // 7% tax
  discount: 0.10,     // 10% off
  tip: 1500           // $15 tip
});
console.log(paymentLink.url);

In this flow:

  1. Pages Kit sends selected items + optional modifiers.
  2. Payment Kit creates a temporary product/price session with these values.
  3. It returns a ready-to-use checkout_url tied to that DID session.

This would allow any Pages Kit app to generate dynamic payment links — fully automated, secure, and DID-authenticated — without needing pre-created price IDs or backend API keys.

Since cart checkouts already create ephemeral sessions, this enhancement feels like a natural extension of the current system. It would unlock flexible, real-world billing for all creators and developers using ArcBlock.

Is something like this possible and if so on any part of the roadmap?

Thanks for all your building!

JianChao11个月前

tax_rate/discount/tip 需要动态设置,是针对单个用户自定义还是多个用户自定义?

回复