Is it possible to use the instructions held by dfx from Rust's crate (code)?

We offer the ability to wrap cdk’s to create canisters with their own features on them. We also provide a CLI tool using the dfx binary internally to deploy these canisters.

CLI tool: GitHub - horizonx-tech/chainsight-cli
CDK wrapper: GitHub - horizonx-tech/chainsight-sdk

The CLI tool works on the assumption that the dfx binary is installed internally, but version control of that dfx and handling (or QA, etc.) through dfx usage is difficult.

Is it possible to use dfx functionality in rust code? Or are there possible recommendations for achieving something similar?
It seems that dfx is deeply dependent on dfx-core in the sdk repository, but as dfx-core is not published on crates.io and does not seem to be versioned for publication, I wonder if using dfx-core directly is not recommended.

There aren’t plans to publish or version it, so you will need a git dependency with a rev key, but the reason it exists is to be used by the community. However, some of the things you are doing may not be part of it yet. If you find something missing (that is ‘DFX functionality’ rather than ‘IC functionality’), tell us at the DX feedback board - one missing piece that we already know about is building canisters.

I understood that there are no plans for public disclosure.

If you find something missing (that is ‘DFX functionality’ rather than ‘IC functionality’), tell us at the DX feedback board - one missing piece that we already know about is building canisters.

I don’t think dfx itself lacks functionality. We just want to use dfx (or its functionality) as a library to create a CLI with the basic functionality of dfx plus additional operations to treat it as a canister for our platform.

For example, in a dfx build the candid interface is added to the metadata, but then we use ic-wasm (ic-wasm is exposed as a library) to add our own metadata which means it is part of our platform. Other times, dfx deploy allows us to deploy a canister, but then call a defined function to initialise it for our platform’s canister, for example, combining several dfx commands into a single command, or executing a dfx command on top of using other libraries.

I believe that there may be a desire to wrap dfx and execute commands in this way.
Is there a recommended way to deal with this that others have done or recommend without exposing dfx?

Could an extension-defined canister type be the solution to your problem?

It may be a usable technology if the structure is significantly changed, but it is difficult to do so.

Is there a recommended way to deal with this that others have done or recommend without exposing dfx?

I only want to make good use of the dfx commands on their own in rust, can I get an answer to this context?

Then I think the way suggested by Adam above is the way to go

1 Like

I meant, if you find something that is DFX-specific but absent from dfx-core.

1 Like