onflow / onflow/flow-cli

CLI command to transform contract code to hex with imports replaced

Open
#1,157 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Feedback
Dominant language
Go
Stars
209
Forks
87
Avg merge
1d 17h
Merged PRs (30d)
3

Description

Issue To Be Solved

I'm working on contract to aid in delegated contract updates, and this includes storing contract code in onchain resources. The easiest way to pass around contract code is as a hex string and convert it to a byte array in the transaction. However, hexifying the .cdc file contents with non-native utils means I need to explicitly state the import addresses.

It would be really helpful if I could tap into Flow CLI's import syntax replacement to handle this for me.

Suggest A Solution

Add a flow command that takes a contract file location and returns the code as a hex string, something like

flow hexify ./contracts/Foo.cdc --network emulator # returns 70756...0a7d

Where the CLI replaces import addresses in Foo according to the aliases set for the specified network and returns the resulting contract code as hex.

Context

Mentioned above

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating Flow CLI's existing import syntax replacement and the network alias handling mentioned in the issue. Define the new command's arguments and output around a contract file, such as ./contracts/Foo.cdc, and verify that --network emulator produces hex code with imports replaced according to that network's aliases.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
blockchain, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.