Post
Share your knowledge.
How to call `public fun`s from Sui framework using CLI?
Hey folks, I'm trying to call public functions from the Sui framework using the Sui CLI. For instance, if someone transfers an object to me and I don't want it, how can I freeze it? I thought about using sui client call
, but I'm having trouble with the module identifier. Is publishing a wrapper package the only way, or is there a CLI command I'm missing?
- Move CLI
- Move
Answers
2I actually figured this out using sui client ptb
: sui client ptb --move-call 0x2::transfer::public_freeze_object "<0x7a7e054896810bbbe031041ee131137c417fdf8320ba40ec47203e1ab4b8f7e1::example::Sword>" @0xbcb2c3c6b0f67828fce9702115b914414df767a35c8a541413787d0a1e66682e
, at least on the testnet. You just need the correct type for the call, although I'm not certain if the key
makes it implement a specific trait.
It's possible to call public functions from Sui framework packages via the Sui CLI, but with some limitations. For instance, accessing certain system modules like 0x2 directly isn't fully supported yet. A common workaround is to publish a custom package that wraps the desired function like public_freeze_object
, allowing you to call it with your object ID as a parameter. This gives more flexibility. Feel free to reach out if you need help creating this wrapper package!
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.