Serialize script return value to Cadence json
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 209
- Forks
- 87
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 3
Description
Issue To Be Solved
It would be really great if script return values could be serialized into Cadence json and saved locally.
Suggest A Solution
A flag added to flow scripts ... like --serialize-to <FILENAME.json>. Say I have a script like:
access(all) fun main(): UInt64 {
return getCurrentBlock().height
}
That I run with the command:
flow scripts execute ./scripts/get_current_block_height.cdc --serialize-to block-height.json
Where block-height.json looks like
[
{
"type": "UInt64",
"value": "70027781"
}
]
This would allow me to script the following:
#!/bin/bash
flow scripts execute ./scripts/get_current_block_height.cdc --serialize-to block-height.json
flow transactions execute ./transactions/set_minimum_block_height.cdc --args-json "$(cat block-height.json)"
Where the script result is used as args for the subsequent transaction execution.
Context
Not a blocker, just an idea.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the flow scripts execute command and its existing output handling, then compare it with transaction --args-json parsing. Define how script return values map to the requested Cadence JSON file and how the --serialize-to flag behaves for errors and multiple values. Done means the command writes the shown JSON shape and the resulting file can be passed to flow transactions execute --args-json.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100