-
Notifications
You must be signed in to change notification settings - Fork 121
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
Changes from 250 commits
c87b62f
b1dde94
ef6a62d
2694631
c7ed146
3d49c67
0cd6a71
5c6657a
8dfc55a
6177275
05a2a6a
f9cf556
b221475
63268ea
be37527
018800d
720ed47
bce0c92
0a7968c
4d20da5
272beec
44649b9
3a68efe
abd959d
4ec6409
9ace541
c688b04
9a07cd3
de49f2d
5d5f7be
6bb285a
32e1ac2
5ad2f9a
e02c0ad
d548a27
9681649
b1d2356
c0316f0
e185135
c87ae61
3a9c170
71d6b99
6238acc
53c8cf0
41a454e
f9fb375
3a5825b
c9a4df5
b801b55
968a65d
c74cc2b
9ca13a2
1def295
c9cf366
dc86eb8
f070a40
5dfea3f
935108a
94dcfb3
81b3100
1beab44
838f323
9065a77
238f1ad
6b5e0aa
a919b07
2ad664d
de7aef0
6286970
f4a04b6
80a29a3
44c8136
a5ff4c8
9efcfcc
95db693
62d92d5
c477fb7
5d80deb
cd2f66c
aa1582a
2ffd38d
fe8334a
aed54bf
6abf0f2
1b01370
29532d4
3e7e515
e5dc448
169ca6f
bd5a9aa
f7d5d29
2cebd0e
f8792bf
9bb545d
8237f17
7338104
b6b0df7
0d79181
0f2f5c5
f3a899b
1356c64
d962d3d
35d9676
a741d5b
dd344b9
5bc0ca8
e8c6035
6a36ef3
3c2f293
ea3662c
d21ee04
d4f54d9
d7327a5
cd90e11
d866137
2faa4b8
010e56c
b13af2b
53ae3de
d8ddc5e
be05b0f
d070507
1335205
cb9e318
1fa9d72
ed966ad
01e2b2a
b4aa4d0
fb8306c
1125d75
de0d437
e98d035
073433f
885a6dc
1001e8c
7cabc62
ac3db3f
1667a28
facb214
1d8185c
bf46a06
5e80a0e
158b3d9
8e9f0da
abb77ab
778e714
290291a
8be3b41
6483c03
0dd26ab
57ffc37
53eb4c9
d259efb
cc6f1e2
4153614
18e20f0
0bf5d50
5ad1947
2da3236
8355b68
e71a2c2
64817a7
cc89ae2
bf2bdab
0ab8a4c
d7e558c
94db34d
b16c6f7
3e41a83
c5f5173
b604bf9
922a7bc
423090b
18b4e2a
7df3b95
714546e
627e2c3
78d10bd
2cd9a8b
8f5ba4c
2b85aa4
e40dc80
30086eb
d4d7a86
af2952e
028fd2f
f797967
2666aa2
374426a
6d360fe
d6a16be
1bdb9c7
c86fc62
00bd28d
1af5ae5
3a618f2
ec45215
f0a3bd1
5603d79
f2d9602
ab1410d
a000826
a5e212f
cb6ce97
b1be5c2
766018f
71fe778
9224e26
4508234
49e1cf4
d1766e1
3d24d8c
311ca48
d0e9189
a4efcc5
dfc39ed
2110fce
a4e2a96
25c59dc
cc039c1
986afef
7ab90bc
b0ac525
15df4cb
eaf78b5
ccae20c
fb6228b
60f65a2
fe75ab9
a1de202
e3bf871
4756be5
c126179
ae98818
4612d20
0083ee6
b398606
ca3782e
20603c1
bda2e8e
703330c
0e9ffe7
4351836
08b14a0
9ffc08a
760183b
09669cd
385d91e
1091910
9322082
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"] } | ||
which = "4.2.4" | ||
colored = "2.0.0" | ||
toml = "0.5.8" | ||
|
@@ -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"] } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will probably trigger a dependabot PR for an upgrade to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll keep it as |
||
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" | ||
|
@@ -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 = [] |
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. | ||
|
||
|
||
|
||
|
||
|
This file was deleted.
There was a problem hiding this comment.
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.