2

I have a few simple functions that get data from the blockchain, which normally does not require sending a transaction when using Chainweaver.

(defun get-price (price-key:decimal)
    (at "price" (read price-table price-key ["price"]
)

This function does not change any data, so it shouldn't require gas. How can I use something like the x-wallet browser plugin to call this function and just get the data?

Nexion21
  • 309
  • 2
  • 7

1 Answers1

2

You can just call the local API via HTTP request.

I.e.

localRes = await fetch(
   `${networkUrl}/api/v1/local`, 
  {
    headers: {
      "Content-Type": "application/json",
    },
    method: "POST",
    body: JSON.stringify(cmd),
  };
);

Note: For the cmd - you need to make a valid pact-lang-api command which specifies the smart contract and method to call

Kitty Kad
  • 412
  • 1
  • 7