Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interact with contracts: upload, instantiate and call commands #79

Merged
merged 366 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
366 commits
Select commit Hold shift + click to select a range
c87b62f
WIP display all events
ascjones Oct 26, 2020
b1dde94
Clean up and generalize displaying events
ascjones Oct 26, 2020
ef6a62d
Fix multiple event new lines
ascjones Oct 26, 2020
2694631
Merge branch 'master' into aj-contract-call
ascjones Oct 27, 2020
c7ed146
Fmt
ascjones Oct 27, 2020
3d49c67
Create wrapper types for Display, derive Debug for originals
ascjones Oct 27, 2020
0cd6a71
Control indentation of pretty printing
ascjones Oct 27, 2020
5c6657a
Indent events display
ascjones Oct 27, 2020
8dfc55a
More tuning of runtime events pretty printing
ascjones Oct 27, 2020
6177275
Fmt
ascjones Oct 27, 2020
05a2a6a
Use Display impls for printing events
ascjones Oct 28, 2020
f9cf556
Add DisplayTransferEvent
ascjones Oct 28, 2020
b221475
Namespace events
ascjones Oct 28, 2020
63268ea
Add CodeStored and Instantiated events
ascjones Oct 28, 2020
be37527
Refactor Deploy command and use verbosity for events display
ascjones Oct 28, 2020
018800d
Fix up string message return
ascjones Oct 28, 2020
720ed47
Code hash LowerHex and println after events
ascjones Oct 28, 2020
bce0c92
Use LowerHex api for Bytes
ascjones Oct 28, 2020
0a7968c
Parse code hash with 0x prefix
ascjones Oct 28, 2020
4d20da5
Fmt
ascjones Oct 28, 2020
272beec
Spawn canvas node for integration test
ascjones Oct 29, 2020
44649b9
Increment attempts
ascjones Oct 29, 2020
3a68efe
Get the test running with spawned canvas node
ascjones Oct 30, 2020
abd959d
Instantiate deploy works with manual node
ascjones Oct 30, 2020
4ec6409
Test works locally and cleans up temp dir
ascjones Oct 30, 2020
9ace541
Merge branch 'master' into aj-contract-call
ascjones Oct 30, 2020
c688b04
Fmt
ascjones Oct 30, 2020
9a07cd3
Fix duplicate import
ascjones Oct 30, 2020
de49f2d
Build before testing so cargo-contract bin available for testing
ascjones Oct 30, 2020
5d5f7be
Separate line for build
ascjones Oct 30, 2020
6bb285a
Merge branch 'master' into aj-contract-call
ascjones Nov 2, 2020
32e1ac2
Extract decode_hex util fn
ascjones Nov 3, 2020
5ad2f9a
WIP failing Literal tests for SS58 account ids
ascjones Nov 3, 2020
e02c0ad
Upgrade to nom 0.6
ascjones Nov 6, 2020
d548a27
Use nom error in custom error, impl FromStr
ascjones Nov 9, 2020
9681649
Fmt
ascjones Nov 9, 2020
b1d2356
Merge branch 'master' into aj-contract-call
ascjones Nov 9, 2020
c0316f0
Update lockfile after merge
ascjones Nov 9, 2020
e185135
Merge branch 'master' into aj-contract-call
ascjones Nov 10, 2020
c87ae61
Make TryFrom take reference for verbosity conversion
ascjones Nov 10, 2020
3a9c170
Merge branch 'master' into aj-contract-call
ascjones Nov 10, 2020
71d6b99
Merge branch 'master' into aj-contract-call
ascjones Nov 16, 2020
6238acc
Fix parsing literals
ascjones Nov 16, 2020
53c8cf0
Plumbing for custom encoders
ascjones Nov 18, 2020
41a454e
Implement AccountId32 custom encoder
ascjones Nov 19, 2020
f9fb375
Refactor: extract env types
ascjones Nov 19, 2020
3a5825b
Test for encoding ss58 literal
ascjones Nov 20, 2020
c9a4df5
Fmt and add back failing struct test
ascjones Nov 23, 2020
b801b55
Use AccountId type in test
ascjones Nov 27, 2020
968a65d
Merge branch 'master' into aj-contract-call
ascjones Nov 30, 2020
c74cc2b
TEMP: Use github dependencies of scale-info and ink
ascjones Nov 30, 2020
9ca13a2
Err for 256 bit ints
ascjones Nov 30, 2020
1def295
Use new registry type enumeration
ascjones Nov 30, 2020
c9cf366
Extract type lookup and introduce Encoder
ascjones Nov 30, 2020
dc86eb8
WIP: extract Transcoder and implement env type decoding
ascjones Nov 30, 2020
f070a40
Implement env type decoding, removes generic Input.
ascjones Dec 1, 2020
5dfea3f
Fix AccountId decoding, add some debug logging
ascjones Dec 1, 2020
935108a
Test for different AccountId aliasing
ascjones Dec 1, 2020
94dcfb3
Passing tests for AccountId encoding and fmt
ascjones Dec 1, 2020
81b3100
Merge branch 'master' into aj-contract-call
ascjones Dec 1, 2020
1beab44
Merge branch 'master' into aj-contract-call
ascjones Jan 20, 2021
838f323
Merge branch 'master' into aj-contract-call
ascjones Mar 16, 2021
9065a77
Merge branch 'master' into aj-contract-call
ascjones Sep 9, 2021
238f1ad
Update scale-info and ink deps, patch ink deps for now
ascjones Sep 9, 2021
6b5e0aa
Update scale-info and ink deps, patch ink deps for now
ascjones Sep 9, 2021
a919b07
Remove extrinsics feature
ascjones Sep 9, 2021
2ad664d
Dependencies
ascjones Sep 9, 2021
de7aef0
More deps
ascjones Sep 9, 2021
6286970
Cargo.lock
ascjones Sep 9, 2021
f4a04b6
Merge branch 'master' into aj-contract-call
ascjones Sep 9, 2021
80a29a3
Cargo.lock
ascjones Sep 9, 2021
44c8136
WIP upgrading to latest subxt and scale-info
ascjones Sep 20, 2021
a5ff4c8
More upgrading to latest subxt
ascjones Sep 20, 2021
9efcfcc
Fix more errors
ascjones Sep 21, 2021
95db693
Fix up extrinsic commands
ascjones Sep 21, 2021
62d92d5
Refactor transcoder decode, handle Compact
ascjones Sep 21, 2021
c477fb7
Refactor transcoder encode, initial compact support
ascjones Sep 21, 2021
5d80deb
Fmt
ascjones Sep 21, 2021
cd2f66c
Fix metadata file loading
ascjones Sep 21, 2021
aa1582a
Constructor arg rename
ascjones Sep 21, 2021
2ffd38d
Enable tokio
ascjones Sep 21, 2021
fe8334a
Make instantiate work
ascjones Sep 22, 2021
aed54bf
Update contracts runtime from substrate-contracts-node
ascjones Sep 22, 2021
6abf0f2
Fix warnings and add todo
ascjones Sep 22, 2021
1b01370
Update subxt
ascjones Sep 22, 2021
29532d4
Add missing import
ascjones Sep 29, 2021
3e7e515
Use explicit substrate branch to match subxt import
ascjones Sep 29, 2021
e5dc448
Remove sp_rpc dependency
ascjones Sep 29, 2021
169ca6f
Remove sp_rpc dependency
ascjones Sep 29, 2021
bd5a9aa
Use metadata to decode events
ascjones Sep 30, 2021
f7d5d29
Fmt
ascjones Sep 30, 2021
2cebd0e
Pretty print events
ascjones Sep 30, 2021
f8792bf
WIP custom transcoders for events
ascjones Sep 30, 2021
9bb545d
Custom transcoders for events working
ascjones Oct 1, 2021
8237f17
Fix some warnings
ascjones Oct 1, 2021
7338104
Slim down bat dependency
ascjones Oct 1, 2021
b6b0df7
Decode contract events
ascjones Oct 1, 2021
0d79181
Use correct field for instantiated contract account
ascjones Oct 1, 2021
0f2f5c5
Fix warnings
ascjones Oct 1, 2021
f3a899b
Fix multiple line warning
ascjones Oct 1, 2021
1356c64
Update contracts RPC types
ascjones Oct 1, 2021
d962d3d
Fmt
ascjones Oct 1, 2021
35d9676
Fix deploy contract account
ascjones Oct 1, 2021
a741d5b
Use ink! master branch
ascjones Oct 11, 2021
dd344b9
Oops
ascjones Oct 11, 2021
5bc0ca8
Merge branch 'master' into aj-contract-call
ascjones Oct 19, 2021
e8c6035
Remove patches
ascjones Oct 19, 2021
6a36ef3
Bump ink deps to rc6
ascjones Oct 19, 2021
3c2f293
Update to latest subxt
ascjones Oct 19, 2021
ea3662c
Update to latest subxt
ascjones Oct 26, 2021
d21ee04
Fix errors after subxt update
ascjones Oct 26, 2021
d4f54d9
Fix instantiate_with_code.rs
ascjones Oct 26, 2021
d7327a5
Merge branch 'master' into aj-contract-call
ascjones Nov 9, 2021
cd90e11
Update subxt
ascjones Nov 22, 2021
d866137
Add deserializing context
ascjones Nov 22, 2021
2faa4b8
Fmt
ascjones Nov 22, 2021
010e56c
Expose public metadata fields
ascjones Nov 22, 2021
b13af2b
Implement full metadata decoding
ascjones Nov 22, 2021
53ae3de
Merge branch 'master' into aj-contract-call
ascjones Nov 29, 2021
d8ddc5e
Cargo.lock
ascjones Nov 29, 2021
be05b0f
Update calls to work with storage_gas_limit from https://github.com/p…
ascjones Nov 29, 2021
d070507
Merge branch 'master' into aj-contract-call
ascjones Nov 29, 2021
1335205
Cargo.lock
ascjones Nov 29, 2021
cb9e318
Merge branch 'master' into aj-contract-call
ascjones Dec 10, 2021
1fa9d72
Update to latest subxt
ascjones Dec 10, 2021
ed966ad
Fmt
ascjones Dec 10, 2021
01e2b2a
WIP unify instantiate command
ascjones Dec 13, 2021
b4aa4d0
Fix call command errors
ascjones Dec 13, 2021
fb8306c
Main warning unused result
ascjones Dec 13, 2021
1125d75
Call and instantiate warns and errors and fmt
ascjones Dec 13, 2021
de0d437
Update to ink rc7
ascjones Dec 13, 2021
e98d035
Default to local contract wasm if none specified
ascjones Dec 13, 2021
073433f
Change instantiate endowment to value
ascjones Dec 14, 2021
885a6dc
Use latest subxt branch
ascjones Dec 17, 2021
1001e8c
Update to latest subxt
ascjones Dec 17, 2021
7cabc62
Unify call and instantiate arg names
ascjones Dec 17, 2021
ac3db3f
Instantiate and call args consistency
ascjones Dec 17, 2021
1667a28
Add todo comment for encoding message args
ascjones Dec 17, 2021
facb214
Refactor, tidy up call and instantiate
ascjones Dec 17, 2021
1d8185c
Display decoded contract event separately
ascjones Dec 17, 2021
bf46a06
Register env types with and without aliases
ascjones Dec 20, 2021
5e80a0e
Add pretty print flag
ascjones Dec 20, 2021
158b3d9
WIP add upload
ascjones Dec 20, 2021
8e9f0da
Wiring up upload code extrinsic
ascjones Dec 20, 2021
abb77ab
Download latest contracts node metadata
ascjones Dec 21, 2021
778e714
Wire up upload command and WIP manifest path
ascjones Dec 21, 2021
290291a
Merge branch 'master' into aj-contract-call
ascjones Dec 21, 2021
8be3b41
in! default features and cargo update
ascjones Dec 21, 2021
6483c03
Add manifest path argument for extrinsics
ascjones Dec 21, 2021
0dd26ab
Only fetch crate metadata once
ascjones Dec 21, 2021
57ffc37
Fmt
ascjones Dec 21, 2021
53eb4c9
Cargo upgrade
ascjones Dec 21, 2021
d259efb
Update substrate dependencies
ascjones Dec 21, 2021
cc6f1e2
Pretty print code upload dry run values
ascjones Dec 21, 2021
4153614
Extract name value println macro
ascjones Dec 22, 2021
18e20f0
Print code hash from upload extrinsic
ascjones Dec 22, 2021
0bf5d50
Refactor upload code command
ascjones Dec 22, 2021
5ad1947
Pretty print instantiate results
ascjones Dec 22, 2021
2da3236
Add salt arg to instantiate command
ascjones Dec 22, 2021
8355b68
WIP custom events display, removes big bat dep
ascjones Dec 29, 2021
e71a2c2
Extract method for printing RPC contract result
ascjones Jan 4, 2022
64817a7
Ugly printing of events
ascjones Jan 4, 2022
cc89ae2
Fix contract event decoding
ascjones Jan 4, 2022
bf2bdab
Fmt
ascjones Jan 4, 2022
0ab8a4c
Pretty print event fields
ascjones Jan 6, 2022
d7e558c
Only print event fields if verbose
ascjones Jan 6, 2022
94db34d
More event prettification
ascjones Jan 7, 2022
b16c6f7
Fmt
ascjones Jan 7, 2022
3e41a83
Resolve some todos
ascjones Jan 7, 2022
c5f5173
Remove some code comments, moved to follow ups in PR
ascjones Jan 8, 2022
b604bf9
Refactor: extract compact encoding function
ascjones Jan 8, 2022
922a7bc
Fix storage_deposit_limit and add todo re: compact primitives
ascjones Jan 8, 2022
423090b
Add todo re: compact primitives
ascjones Jan 8, 2022
18b4e2a
Merge branch 'master' into aj-contract-call
ascjones Jan 26, 2022
7df3b95
Cargo.lock
ascjones Jan 26, 2022
714546e
Use released substrate crates and subxt master
ascjones Jan 26, 2022
627e2c3
Fix encoding compact, inline for each uint
ascjones Jan 26, 2022
78d10bd
Fix encoding compact, inline for each uint
ascjones Jan 26, 2022
2cd9a8b
Add extrinsics markdown outline
ascjones Jan 28, 2022
8f5ba4c
Dynamic compact encoding
ascjones Jan 31, 2022
2b85aa4
Replace bitvec todos with errs, added follow up in PR
ascjones Jan 31, 2022
e40dc80
Remove todo about friendly encoding error, add to PR follow ups
ascjones Jan 31, 2022
30086eb
Rename codec to scale for test contract, fix some transcoding tests
ascjones Jan 31, 2022
d4d7a86
Attempt to fix linking with __ink_generate_metadata
ascjones Jan 31, 2022
af2952e
Update to ink rc8
ascjones Jan 31, 2022
028fd2f
Add test for out of order composite fields
ascjones Jan 31, 2022
f797967
Update ink metadata version
ascjones Feb 1, 2022
2666aa2
Update ink metadata types and methods
ascjones Feb 1, 2022
374426a
Fix metadata error message
ascjones Feb 1, 2022
6d360fe
Add std feature to fix test compilation with inline contract
ascjones Feb 2, 2022
d6a16be
Fix out of order struct fields
ascjones Feb 2, 2022
1bdb9c7
Improve encoding of field error message
ascjones Feb 2, 2022
c86fc62
Fmt imports
ascjones Feb 2, 2022
00bd28d
Rename TypeLookupId to TypeLookup
ascjones Feb 2, 2022
1af5ae5
Remove alias matching for custom env type transcoding
ascjones Feb 3, 2022
3a618f2
Fix variant encoding for maps and out of order fields
ascjones Feb 3, 2022
ec45215
Add failing test & impl for compact struct transcoding
ascjones Feb 3, 2022
f0a3bd1
Use released version of pallet-contracts primitives
ascjones Feb 4, 2022
5603d79
WIP attempting to fix compact struct transcoding
ascjones Feb 4, 2022
f2d9602
Fix compact struct decoding
ascjones Feb 4, 2022
ab1410d
Add todo for integration test
ascjones Feb 7, 2022
a000826
Renamed SconParseError
ascjones Feb 7, 2022
a5e212f
Failing test for invalid integer
ascjones Feb 7, 2022
cb6ce97
Use nom-supreme for combinators, error handling
ascjones Feb 7, 2022
b1be5c2
Use released subxt
ascjones Feb 8, 2022
766018f
Refactor integer parsing
ascjones Feb 8, 2022
71fe778
Refactor char parsing
ascjones Feb 8, 2022
9224e26
Refactor seq parsing
ascjones Feb 8, 2022
4508234
Refactor tuple parsing
ascjones Feb 8, 2022
49e1cf4
Refactor unit tuple parsing
ascjones Feb 8, 2022
d1766e1
Refactor map parsing
ascjones Feb 8, 2022
3d24d8c
Refactor bytes parsing
ascjones Feb 8, 2022
311ca48
Remove final nom `map` free function usage
ascjones Feb 8, 2022
d0e9189
Use some postfix recognizes
ascjones Feb 8, 2022
a4efcc5
Remove final recognize combinator
ascjones Feb 8, 2022
dfc39ed
Use postfix value combinator
ascjones Feb 8, 2022
2110fce
Use opt postfix combinator
ascjones Feb 8, 2022
a4e2a96
Move entry point and top level parser to the top of the file
ascjones Feb 8, 2022
25c59dc
Inline some string parsers
ascjones Feb 8, 2022
cc039c1
Inline some local helper functions
ascjones Feb 8, 2022
986afef
Fix failing integer tests
ascjones Feb 8, 2022
7ab90bc
Fix Rust ident parsing
ascjones Feb 8, 2022
b0ac525
Fix up integration test
ascjones Feb 9, 2022
15df4cb
Make clippy happy
ascjones Feb 9, 2022
eaf78b5
Merge branch 'master' into aj-contract-call
ascjones Feb 9, 2022
ccae20c
Fmt
ascjones Feb 9, 2022
fb6228b
Clippy clippy clippy
ascjones Feb 9, 2022
60f65a2
Ignore integration test for CI
ascjones Feb 9, 2022
fe75ab9
Support parsing underscore separators for integer literals
ascjones Feb 9, 2022
a1de202
+ sign prefix parses to signed int
ascjones Feb 9, 2022
e3bf871
Allow underscores for balance CLI args
ascjones Feb 9, 2022
4756be5
Add helper function for handling runtime errors
ascjones Feb 9, 2022
c126179
Add helper function for displaying runtime module errors
ascjones Feb 9, 2022
ae98818
Elide lifetime
ascjones Feb 9, 2022
4612d20
Add some basic module level docs for transcoding
ascjones Feb 10, 2022
0083ee6
Improve error message where metadata file not found
ascjones Feb 10, 2022
b398606
Adding common args section to extrinsics.md
ascjones Feb 10, 2022
ca3782e
Move --dry-run to extrinisic opts and more docs
ascjones Feb 10, 2022
20603c1
Move --storage-deposit-limit to ExtrinsicOpts, move ExtrinsicOpts to …
ascjones Feb 10, 2022
bda2e8e
Add instantiate docs
ascjones Feb 10, 2022
703330c
Add call docs
ascjones Feb 10, 2022
0e9ffe7
Update Extrinsics docs
ascjones Feb 10, 2022
4351836
Update Cargo.toml
ascjones Feb 14, 2022
08b14a0
Don't wait for finalization before displaying transaction success
ascjones Feb 14, 2022
9ffc08a
Update docs/extrinsics.md
ascjones Feb 14, 2022
760183b
Remove static error detail lookup, since it may be inaccurate if the …
ascjones Feb 14, 2022
09669cd
CLIPPY
ascjones Feb 14, 2022
385d91e
Print debug message lines
ascjones Feb 14, 2022
1091910
Display not Debug return value
ascjones Feb 14, 2022
9322082
Fmt
ascjones Feb 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,000 changes: 1,685 additions & 1,315 deletions Cargo.lock

Large diffs are not rendered by default.

51 changes: 36 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ heck = "0.4.0"
zip = { version = "0.5.13", default-features = false }
parity-wasm = "0.42.2"
cargo_metadata = "0.14.1"
codec = { package = "parity-scale-codec", version = "2.3.1", features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.3.1", features = ["derive"] }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed because I have an embedded contract for testing purposes and ink! generates code with ::scale imports.

which = "4.2.4"
colored = "2.0.0"
toml = "0.5.8"
Expand All @@ -43,14 +43,26 @@ url = { version = "2.2.2", features = ["serde"] }
impl-serde = "0.3.2"
regex = "1.5.4"

# dependencies for optional extrinsics feature
async-std = { version = "1.10.0", optional = true }
sp-core = { version = "2.0.1", optional = true }
subxt = { version = "0.14.0", package = "substrate-subxt", optional = true }
futures = { version = "0.3.21", optional = true }
hex = { version = "0.4.3", optional = true }

funty = "2.0.0"
# dependencies for extrinsics (deploying and calling a contract)
async-std = { version = "1.10.0", features = ["attributes", "tokio1"] }
ink_metadata = { version = "3.0.0-rc8", features = ["derive"] }
ink_env = "3.0.0-rc8"
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably trigger a dependabot PR for an upgrade to 2.0.0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep it as 1.0.0 for now since that is the same version as ink_metadata rc8 is using.

sp-arithmetic = "4.0.0"
sp-core = "5.0.0"
sp-keyring = "4.0.0"
ascjones marked this conversation as resolved.
Show resolved Hide resolved
sp-runtime = "5.0.0"
pallet-contracts-primitives = "5.0.0"
subxt = "0.17.0"
futures = "0.3.19"
hex = "0.4.3"
jsonrpsee = { version = "0.6.1", features = ["ws-client"] }
nom = "7.1.0"
nom-supreme = "0.6.0"
indexmap = "1.8.0"
thiserror = "1.0.30"
escape8259 = "0.5.1"
itertools = "0.10.3"

[build-dependencies]
anyhow = "1.0.53"
Expand All @@ -60,19 +72,28 @@ substrate-build-script-utils = "3.0.0"
platforms = "2.0.0"

[dev-dependencies]
assert_cmd = "2.0.4"
assert_matches = "1.5.0"
pretty_assertions = "1.1.0"
wabt = "0.10.0"
regex = "1.5.4"
predicates = "2.1.1"

[features]
default = []
ink_primitives = "3.0.0-rc8"
ink_storage = "3.0.0-rc8"
ink_lang = "3.0.0-rc8"

# Enable this for (experimental) commands to deploy, instantiate and call contracts.
#
# Disabled by default
extrinsics = ["sp-core", "subxt", "async-std", "futures", "hex"]
[features]
# This `std` feature is required for testing using an inline contract's metadata, because `ink!` annotates the metadata
# generation code with `#[cfg(feature = "std")]`.
default = ["std"]
std = []

# Enable this to execute long running tests, which usually are only run on the CI server
#
# Disabled by default
test-ci-only = []

# Enable this to execute tests which depend on a locally running contracts enabed chain
# e.g.https://github.com/paritytech/canvas-node
integration-tests = []
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ artifact to the `target/` directory.

Runs test suites defined for a smart contract off-chain.

##### `cargo contract upload`

Upload a contract to a `pallet-contracts` enabled chain. See [extrinsics](docs/extrinsics.md).

##### `cargo contract instantiate`

Create an instance of a contract on chain. See [extrinsics](docs/extrinsics.md).

##### `cargo contract call`

Invoke a message on an existing contract on chain. See [extrinsics](docs/extrinsics.md).

## License

The entire code within this repository is licensed under the [GPLv3](LICENSE).
Expand Down
103 changes: 103 additions & 0 deletions docs/extrinsics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Extrinsics
`cargo-contract` provides CLI support for uploading, instantiating and calling your contracts directly from the command
line.

## Common arguments

```
--suri
```
The Secret URI used for signing the extrinsic. For development chains, the well known endowed accounts can be used e.g.
`//Alice`. For other accounts, the actual secret key must be provided e.g. an `0x` prefixed 64 bit hex string, or the
seed phrase. See usage of [`subkey`](https://docs.substrate.io/v3/tools/subkey/) for examples, and docs for the expected
values in the [parsing code](https://docs.rs/sp-core/latest/sp_core/crypto/trait.Pair.html#method.from_string_with_seed).

:warning: **WARNING** :warning:

It is strongly recommended NOT to use secret keys from actual value bearing chains on the command line, since they are
visible on screen and are often saved to the command line shell's history. For now this tool should only be used for
development and testnets. It is a priority to implement a safer method of signing here before using this tool with value
bearing chains.

```
--password
```
*Optional*. The password for the `--suri`, see https://docs.substrate.io/v3/tools/subkey/#password-protected-keys.

```
--manfest-path
ascjones marked this conversation as resolved.
Show resolved Hide resolved
```
*Optional*. The path to the `Cargo.toml` of the contract crate. Use this to run commands on a contract from outside of
its project directory.

```
--url
```
*Optional*. The websockets url of an RPC node on the target chain. Defaults to a locally running node at
"ws://localhost:9944".

```
---dry-run
```
*Optional*. All extrinsic commands can be run without altering the chain state. Useful for testing if a command will be
successful, estimating gas costs or querying the result of `ink!` readonly messages.

```
--storage-deposit-limit
```
*Optional*. The maximum amount of balance that can be charged from the caller to pay for the storage consumed.

## Commands

### `upload`

Upload the Wasm code of the contract to the target chain. Invokes the [`upload_code`](https://github.com/paritytech/substrate/blob/master/frame/contracts/src/lib.rs#L509)
dispatchable.

e.g. `cargo contract upload --suri //Alice`

Assumes that `cargo contract build` has already been run to produce the contract artifacts.

### `instantiate`

Create an instance of a contract on chain. If the code has already been uploaded via `upload`, specify the resulting
`--code-hash` which will result in a call to [`instantiate`](https://github.com/paritytech/substrate/blob/master/frame/contracts/src/lib.rs#L460).
If no `--code-hash` is specified it will attempt to both upload the code and instantiate via the
[`instantiate_with_code`](https://github.com/paritytech/substrate/blob/master/frame/contracts/src/lib.rs#L419)
dispatchable.

e.g.
```
cargo contract instantiate \
--constructor new \
--args false \
--suri //Alice \
--code-hash 0xbc1b42256696c8a4187ec3ed79fc602789fc11287c4c30926f5e31ed8169574e
```
- `--constructor` the name of the contract constructor method to invoke.
- `--args` accepts a space separated list of values, encoded in order as the arguments of the constructor to invoke.
- `--code-hash` the hash of the uploaded code, returned from a call to `contract upload` or a previous
`contract instantiate`

### `call`

Invoke a message on an instance of a contract via the [`call`](https://github.com/paritytech/substrate/blob/master/frame/contracts/src/lib.rs#L359)
dispatchable.

e.g.
```
cargo contract call \
--contract 5FKy7RwXBCCACCEPjM5WugkhUd787FjdgieTkdj7TPngJzxN \
--message transfer \
--args 5FKy7RwXBCCACCEPjM5WugkhUd787FjdgieTkdj7TPngJzxN 1000 \
--suri //Alice
```

- `--contract` the account id of the contract to invoke, returned after a successful `contract instantiate`.
- `--message` the name of the contract message to invoke.
- `--args` accepts a space separated list of values, encoded in order as the arguments of the message to invoke.





111 changes: 0 additions & 111 deletions src/cmd/deploy.rs

This file was deleted.

Loading