Interact with contracts: upload, instantiate and call commands
Created by: ascjones
Adds upload
, instantiate
and call
commands which allows interacting with contracts on live chains with a compatible pallet-contracts
.
Upload
cargo contract upload --suri //Alice --dry-run
cargo contract upload --suri //Alice
Instantiate
cargo contract instantiate \
--constructor new \
--args false \
--suri //Alice \
--code-hash 0xbc1b42256696c8a4187ec3ed79fc602789fc11287c4c30926f5e31ed8169574e \
--dry-run
cargo contract instantiate \
--constructor new \
--args false \
--suri //Alice \
--code-hash 0xbc1b42256696c8a4187ec3ed79fc602789fc11287c4c30926f5e31ed8169574e
Instantiate with code
Omitting --code-hash
will call instantiate_with_code
:
Call
cargo contract call \
--contract 5FQNUFjuSxjB1o67CneHXieB1Hy6xAj2A4h4dUVLCvNkgRmD \
--message flip \
--suri //Alice \
--dry-run
cargo contract call \
--contract 5FQNUFjuSxjB1o67CneHXieB1Hy6xAj2A4h4dUVLCvNkgRmD \
--message flip \
--suri //Alice
cargo contract call \
--contract 5FQNUFjuSxjB1o67CneHXieB1Hy6xAj2A4h4dUVLCvNkgRmD \
--message get \
--suri //Alice \
--dry-run
Debug message
If the contract is build in debug mode then
Will result in...
Todo
-
Display all events resulting from Call
-
Optional 0x
prefix for hex encoded code hash -
SS58 AccountIds -
Release and use pallet-contracts-primitives
andsp-rpc
fromcrates.io
-
Documentation -
CLI usage help -
extrinsics.md -
transcoding/scon code docs
-
Follow ups
These will be promoted to their own issue, or into separate issues for following up once this is merged.
- Signing: safer alternatives for value bearing chains than providing secret key on the command line. Possibly allow using encrypted file with private key, or integrating with external signers somehow.
- Dynamic
DispatchError::Module
errors, so that error details are displayed correctly across different chains https://github.com/paritytech/subxt/issues/443 - Gas estimation: auto dry run first to use estimated gas as a value for the gas limit when running actual call.
- Add flag
--wait-for-finalization
. so that success/events are not displayed until the block is finalized - Denominated units for Balances e.g.
100CAN
,1MCAN
- Bitvec encoding/decoding
- Improve error message when failing to encode contract message arg https://github.com/paritytech/cargo-contract/pull/79/commits/e40dc8051b37074afad69f18ccdc35e1de408dd8
- Set up CI with
substrate-contracts-node
and unignore integration test: https://github.com/paritytech/cargo-contract/blob/60f65a2863be1266882bdd81861d836baeb06724/src/cmd/extrinsics/integration_tests.rs#L124 - Add support for remove_code extrinsic.