flow-cli
flow-cli copied to clipboard
Serialize script return value to Cadence json
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.