clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

Ability to call a read-only function in devnet from deployment plans

Open friedger opened this issue 2 years ago • 10 comments

To test smart contracts, I run clarinet integrate. I step through the block manually, from time to time I run an additional deployment plan.

I thought, I could include a read-only call in the deployment plan so that I see the current state of the blockchain/contract without writing additional javascript code to call read-only functions.

I tried to use a deployment plan to call a read-only function. It fails with following error:

{"error":"transaction rejected","reason":"NoSuchPublicFunction","txid":"1c7a98a37d718c116e77e63d5343ab5d9ab29d6e1586e0dce99802594ed6fa64"}

Is there a way to get the chain object of the devnet so that I can use function callReadOnlyFn from deno lib clarinet?

friedger avatar Feb 07 '23 23:02 friedger

I'll have a look

hugoclrd avatar Feb 22 '23 19:02 hugoclrd

@hugocaillard and @lgalabru to discuss feasibility & add priority & sizing.

smcclellan avatar Apr 19 '23 15:04 smcclellan

I usually write a simple helper contact that wraps read-only functions in public functions

friedger avatar Apr 19 '23 22:04 friedger

Looking fro more details, are we talking about simnet or devnet @friedger?

hugoclrd avatar Apr 26 '23 14:04 hugoclrd

@friedger Does this bit of (low-visibility) docs help?

Read-only functions and functions that take no arguments are passed an empty list like so: parameters: []

mefrem avatar Apr 28 '23 14:04 mefrem

Devnet. Via Deployment plans? No. I would need to use another tool like node fetch?

friedger avatar Apr 28 '23 18:04 friedger

Hello @friedger,

It seems like this issue is leading to confusing. Could you refine the original description with more details?

  • What you tried to do?
  • Why? Use case?
  • What the current behavior (that, you already provided)
  • What would be the expected behavior? (Or behaviors if you think there are multiple options)

Thank you 🙏

hugoclrd avatar Jun 27 '23 15:06 hugoclrd

What you tried to do? Why? Use case?

Use clarinet integrate and not write and js code

What the current behavior (that, you already provided)

Currently, I wrap read-only functions in a helper contract, then I can call this helper contract to get the result of the read-only function via a deployment plan.

What would be the expected behavior? (Or behaviors if you think there are multiple options)

I am looking for a way to call a read-only function without the wrapper and without js code.

friedger avatar Jun 28 '23 16:06 friedger

@friedger Do you have a repo or a config/code snippet that shows how you call the public-function wrapper?

hugoclrd avatar Jun 28 '23 17:06 hugoclrd

@hugocaillard Here is the helper: https://github.com/friedger/clarity-stacking-pools/blob/main/contracts/testing/helper.clar and here is the deployment plan: https://github.com/friedger/clarity-stacking-pools/blob/main/deployments/1-alice-delegate.devnet-plan.yaml

friedger avatar Jun 29 '23 11:06 friedger