Skip to content

Commit 3aa48c9

Browse files
tareknaserxermicus
andauthored
Documentation: Solang Aqd (hyperledger-solang#1588)
Adds documentation for [Solang Aqd](https://github.com/hyperledger/solang-aqd), a CLI tool for working with Solana and Polkadot smart contracts. Signed-off-by: Tarek <[email protected]> Co-authored-by: Cyrill Leutwiler <[email protected]>
1 parent 592bd91 commit 3aa48c9

File tree

3 files changed

+317
-9
lines changed

3 files changed

+317
-9
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ Here is a brief description of what we envision for the next versions.
6060

6161
### V0.4
6262

63-
| Feature | Status |
64-
|----------------------------------------------------|-------------|
65-
| Improve management over optimization passes | Not started |
66-
| Adopt single static assignment for code generation | In progress |
67-
| Support openzeppelin on Polkadot target | In progress |
68-
| Provide Solidity -> Polkadot porting guide | Not started |
69-
| Declare accounts for a Solidity function on Solana | In progress |
70-
| Tooling for calls between ink! <> solidity | In progress |
71-
| Provide CLI for node interactions | In progress |
63+
| Feature | Status |
64+
|----------------------------------------------------|------------------------------------------------------|
65+
| Improve management over optimization passes | Not started |
66+
| Adopt single static assignment for code generation | In progress |
67+
| Support openzeppelin on Polkadot target | In progress |
68+
| Provide Solidity -> Polkadot porting guide | Not started |
69+
| Declare accounts for a Solidity function on Solana | In progress |
70+
| Tooling for calls between ink! <> solidity | In progress |
71+
| Provide CLI for node interactions | [Done](https://github.com/hyperledger/solang-aqd) |
7272

7373
## License
7474

docs/aqd.rst

+307
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
Interacting with smart contracts on the command line
2+
====================================================
3+
Solang Aqd (عَقد, meaning "contract" in Arabic), is a Command-Line Interface (CLI) tool
4+
designed for easy interaction with smart contracts on Solana and Polkadot blockchains.
5+
It simplifies the process of deploying smart contracts and executing specific functions on these contracts.
6+
7+
Solang Aqd distinguishes itself by offering seamless integration with Solang-compiled contracts and is actively maintained by the Solang team.
8+
When it comes to Polkadot, Solang Aqd focuses specifically on essential commands for node interactions with on-chain contracts.
9+
In the case of Solana, Solang Aqd fills a notable gap as there currently isn't a dedicated tool for calling specific functions on deployed Solana contracts.
10+
11+
12+
Installation
13+
____________
14+
15+
As of now, the only available method to install ``solang-aqd`` is via Cargo. Run the following command:
16+
17+
.. code-block:: bash
18+
19+
cargo install --force --locked aqd
20+
21+
To update to the latest version, use the same command.
22+
23+
24+
.. note::
25+
26+
If you're interested in a specific target, you can use feature flags. For example, to install with only the Solana target, use:
27+
28+
.. code-block:: bash
29+
30+
cargo install --force --locked aqd --no-default-features --features solana
31+
32+
33+
Submitting extrinsics to Polkadot on-chain
34+
__________________________________________
35+
36+
The command line syntax for interacting with a program deployed on Polkadot is as follows:
37+
38+
aqd polkadot [SUBCOMMAND] [OPTIONS]... [FILE]
39+
40+
The command line is ``aqd polkadot`` followed by a subcommand followed by any options described below,
41+
followed by the filename. The filename could be ``.wasm file``, ``.contract`` bundle, or ``.json`` metadata file.
42+
43+
.. note::
44+
Under the hood, Solang Aqd utilizes ``cargo-contract`` for submitting extrinsics to Polkadot on-chain.
45+
For detailed documentation of specific parameters, please refer to
46+
`contract extrinsics documentation <https://github.com/paritytech/cargo-contract/blob/master/crates/extrinsics/README.md>`_.
47+
48+
General Options (for all subcommands):
49+
++++++++++++++++++++++++++++++++++++++
50+
51+
\-\-url *url*
52+
The websockets URL for the substrate node. [default: ws://localhost:9944]
53+
54+
\-\-network *network*
55+
Specify the network name to use.
56+
You can either specify a network name or a URL, but not both.
57+
58+
Network:
59+
60+
rococo
61+
Contracts (Rococo) (Equivalent to ``--url wss://rococo-contracts-rpc.polkadot.io``)
62+
63+
phala-po-c5
64+
Phala PoC-5 (Equivalent to ``--url wss://poc5.phala.network/ws``)
65+
66+
astar-shiden
67+
Astar Shiden (Kusama) (Equivalent to ``--url wss://rpc.shiden.astar.network``)
68+
69+
astar-shibuya
70+
Astar Shibuya (Tokio) (Equivalent to ``--url wss://rpc.shibuya.astar.network``)
71+
72+
astar
73+
Astar (Equivalent to ``--url wss://rpc.astar.network``)
74+
75+
aleph-zero-testnet
76+
Aleph Zero Testnet (Equivalent to ``--url wss://ws.test.azero.dev``)
77+
78+
aleph-zero
79+
Aleph Zero (Equivalent to ``--url wss://ws.azero.dev``)
80+
81+
t3rnt0rn
82+
T3RN T0RN (Equivalent to ``--url wss://ws.t0rn.io``)
83+
84+
pendulum-testnet
85+
Pendulum Testnet (Equivalent to ``--url wss://rpc-foucoco.pendulumchain.tech``)
86+
87+
-s, \-\-suri *suri*
88+
Specifies the secret key URI used for deploying the contract (must be specified). For example:
89+
For a development account: ``//Alice``
90+
91+
With a password: ``//Alice///SECRET_PASSWORD``
92+
93+
-x, \-\-execute
94+
Specifies whether to submit the extrinsic for on-chain execution; if not provided, it will perform a dry run and return the result.
95+
96+
\-\-storage-deposit-limit *storage-deposit-limit*
97+
Specifies the maximum amount of balance that can be charged from the caller to pay for the storage consumed.
98+
99+
\-\-output-json
100+
Specifies whether to export the call output in JSON format.
101+
102+
\-\-help, -h
103+
This displays a short description of all the options
104+
105+
Subcommands:
106+
++++++++++++
107+
108+
Upload Subcommand
109+
-----------------
110+
111+
This subcommand enables the uploading of contracts onto the Polkadot blockchain.
112+
113+
.. code-block:: bash
114+
115+
aqd polkadot upload --suri //Alice -x flipper.contract --output-json
116+
117+
Instantiate Subcommand
118+
----------------------
119+
120+
This subcommand facilitates the instantiation of contracts on the Polkadot blockchain.
121+
122+
.. code-block:: bash
123+
124+
aqd polkadot instantiate --suri //Alice --args true -x --output-json --skip-confirm flipper.contract
125+
126+
Options specific to the ``instantiate`` subcommand:
127+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128+
129+
\-\-constructor *constructor*
130+
Specifies the name of the contract constructor to call. [default: new]
131+
132+
\-\-args *<args>...*
133+
Accepts a space separated list of values, encoded in order as the arguments of the constructor to invoke.
134+
135+
\-\-value *value*
136+
Specifies the value to be transferred as part of the call. [default: 0]
137+
138+
\-\-gas *gas*
139+
Specifies the maximum amount of gas to be used for this command.
140+
141+
\-\-proof-size *proof-size*
142+
Specifies the maximum proof size for this instantiation.
143+
144+
\-\-salt *salt*
145+
Specifies a salt used in the address derivation of the new contract.
146+
147+
-y, \-\-skip-confirm
148+
When set, skips the interactive confirmation prompt.
149+
150+
Call Subcommand
151+
---------------
152+
153+
This subcommand enables the calling of contracts on the Polkadot blockchain.
154+
155+
.. code-block:: bash
156+
157+
aqd polkadot call --contract 5EFYe3hkH2wFK1mLxD5VSqD88hfPZWihXAKeqozZELsL4Ueq --message get --suri //Alice flipper.contract --output-json --skip-confirm
158+
159+
Options specific to the ``call`` subcommand:
160+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161+
162+
\-\-contract *contract*
163+
Specifies the address of the contract to call.
164+
165+
-m, \-\-message *message*
166+
Specifies the name of the contract message to call.
167+
168+
\-\-args *<args>...*
169+
Accepts a space separated list of values, encoded in order as the arguments of the message to invoke.
170+
171+
\-\-value *value*
172+
Specifies the value to be transferred as part of the call. [default: 0]
173+
174+
\-\-gas *gas*
175+
Specifies the maximum amount of gas to be used for this command.
176+
177+
\-\-proof-size *proof-size*
178+
Specifies the maximum proof size for this call.
179+
180+
-y, \-\-skip-confirm
181+
When set, skips the interactive confirmation prompt.
182+
183+
Remove Subcommand
184+
-----------------
185+
186+
This subcommand allows for the removal of contracts from the Polkadot blockchain.
187+
188+
.. code-block:: bash
189+
190+
aqd polkadot remove --suri //Alice --output-json --code-hash 0x94e67200d3d8f0f420873f8d1b426fdf5eb87f208c6e5d061822e017ffaef2a8 flipper.contract
191+
192+
Options specific to the ``remove`` subcommand:
193+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194+
195+
\-\-code-hash *code_hash*
196+
Specifies the code hash to remove.
197+
198+
199+
Interacting with Solana running programs on-chain
200+
_________________________________________________
201+
202+
The command line syntax for interacting with a program deployed on Solana is as follows:
203+
204+
aqd solana [SUBCOMMAND] [OPTIONS]...
205+
206+
It consists of a subcommand followed by its options, both of which are described below.
207+
208+
.. note::
209+
210+
Solang Aqd relies on the local default Solana configuration file to obtain information for transaction submissions.
211+
For comprehensive management of this configuration file, you can refer to `Solana's CLI command documentation <https://docs.solana.com/cli/usage#solana-config>`_.
212+
213+
General Options (for all subcommands):
214+
++++++++++++++++++++++++++++++++++++++
215+
216+
\-\-output-json
217+
Specifies whether to export the call output in JSON format.
218+
219+
\-\-help, -h
220+
This displays a short description of all the options.
221+
222+
Subcommands:
223+
++++++++++++
224+
225+
Deploy Subcommand
226+
------------------
227+
228+
Allows you to deploy Solana compiled programs to Solana.
229+
230+
.. code-block:: bash
231+
232+
aqd solana deploy flipper.so
233+
234+
235+
Show Subcommand
236+
---------------
237+
238+
Show information about a Solana program's instructions given an IDL JSON file.
239+
240+
.. code-block:: bash
241+
242+
aqd solana show --idl flipper.json --instruction new
243+
244+
Options specific to the ``show`` subcommand:
245+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246+
247+
\-\-idl *idl-json-file-path*
248+
Specifies the path of the IDL JSON file.
249+
250+
\-\-instruction *instruction-name*
251+
Specifies the name of the instruction to show information about.
252+
If not specified, information about all instructions is shown.
253+
254+
Call Subcommand
255+
---------------
256+
257+
Allows you to send a custom transaction to a Solana program, enabling the execution of specific functions within the deployed smart contract.
258+
259+
.. code-block:: bash
260+
261+
aqd solana call --idl flipper.json --program G2eBnLvwPCGCFVywrUT2LtKCCYFkGetAVXJfW82UXmPe --instruction new --data true --accounts new self system
262+
263+
To interact with a function on a Solana-deployed smart contract, you'll need to specify key details like the program's address, data arguments, necessary accounts, and signatories.
264+
Solang Aqd simplifies this process by accepting these parameters as command-line arguments.
265+
Additionally, it ensures the submitted transaction aligns with the expected values in the Interface Description Language (IDL).
266+
267+
.. note::
268+
If unsure, you can always check the expected arguements and accounts for a specific function by using the ``show`` subcommand.
269+
270+
Options specific to the ``call`` subcommand:
271+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
272+
273+
\-\-idl *idl-json-file-path*
274+
Specifies the path of the IDL JSON file.
275+
276+
\-\-program *program*
277+
Specifies the program ID of the deployed program.
278+
279+
\-\-instruction *instruction-name*
280+
Specifies the name of the instruction to show information about.
281+
If not specified, information about all instructions is shown.
282+
283+
\-\-program *program*
284+
Specifies the program ID of the deployed program.
285+
286+
\-\-data *<data-arguments>...*
287+
Specifies the data arguments to pass to the instruction.
288+
For arrays and vectors, pass a comma-separated list of values. (e.g. 1,2,3,4).
289+
For structs, pass a JSON string of the struct. (can be a path to a JSON file).
290+
291+
\-\-accounts *<account-arguments>...*
292+
Specifies the accounts arguments to pass to the instruction
293+
294+
Keywords:
295+
296+
new
297+
Creates a new solana account and saves it locally.
298+
299+
self
300+
Reads the default keypair from the local configuration file.
301+
302+
system
303+
Uses the system program ID as the account.
304+
305+
\-\-payer *payer*
306+
Specifies the payer keypair to use for the transaction. [default: local default keypair]
307+

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Contents
3131

3232
installing
3333
running
34+
aqd
3435
extension
3536
examples
3637

0 commit comments

Comments
 (0)