aqd.rst 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. Solang Aqd distinguishes itself by offering seamless integration with Solang-compiled contracts and is actively maintained by the Solang team.
  7. When it comes to Polkadot, Solang Aqd focuses specifically on essential commands for node interactions with on-chain contracts.
  8. 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.
  9. Installation
  10. ____________
  11. As of now, the only available method to install ``solang-aqd`` is via Cargo. Run the following command:
  12. .. code-block:: bash
  13. cargo install --force --locked aqd
  14. To update to the latest version, use the same command.
  15. .. note::
  16. If you're interested in a specific target, you can use feature flags. For example, to install with only the Solana target, use:
  17. .. code-block:: bash
  18. cargo install --force --locked aqd --no-default-features --features solana
  19. Submitting extrinsics to Polkadot on-chain
  20. __________________________________________
  21. The command line syntax for interacting with a program deployed on Polkadot is as follows:
  22. aqd polkadot [SUBCOMMAND] [OPTIONS]... [FILE]
  23. The command line is ``aqd polkadot`` followed by a subcommand followed by any options described below,
  24. followed by the filename. The filename could be ``.wasm file``, ``.contract`` bundle, or ``.json`` metadata file.
  25. .. note::
  26. Under the hood, Solang Aqd utilizes ``cargo-contract`` for submitting extrinsics to Polkadot on-chain.
  27. For detailed documentation of specific parameters, please refer to
  28. `contract extrinsics documentation <https://github.com/paritytech/cargo-contract/blob/master/crates/extrinsics/README.md>`_.
  29. General Options (for all subcommands):
  30. ++++++++++++++++++++++++++++++++++++++
  31. \-\-url *url*
  32. The websockets URL for the substrate node. [default: ws://localhost:9944]
  33. \-\-network *network*
  34. Specify the network name to use.
  35. You can either specify a network name or a URL, but not both.
  36. Network:
  37. rococo
  38. Contracts (Rococo) (Equivalent to ``--url wss://rococo-contracts-rpc.polkadot.io``)
  39. phala-po-c5
  40. Phala PoC-5 (Equivalent to ``--url wss://poc5.phala.network/ws``)
  41. astar-shiden
  42. Astar Shiden (Kusama) (Equivalent to ``--url wss://rpc.shiden.astar.network``)
  43. astar-shibuya
  44. Astar Shibuya (Tokio) (Equivalent to ``--url wss://rpc.shibuya.astar.network``)
  45. astar
  46. Astar (Equivalent to ``--url wss://rpc.astar.network``)
  47. aleph-zero-testnet
  48. Aleph Zero Testnet (Equivalent to ``--url wss://ws.test.azero.dev``)
  49. aleph-zero
  50. Aleph Zero (Equivalent to ``--url wss://ws.azero.dev``)
  51. t3rnt0rn
  52. T3RN T0RN (Equivalent to ``--url wss://ws.t0rn.io``)
  53. pendulum-testnet
  54. Pendulum Testnet (Equivalent to ``--url wss://rpc-foucoco.pendulumchain.tech``)
  55. -s, \-\-suri *suri*
  56. Specifies the secret key URI used for deploying the contract (must be specified). For example:
  57. For a development account: ``//Alice``
  58. With a password: ``//Alice///SECRET_PASSWORD``
  59. -x, \-\-execute
  60. Specifies whether to submit the extrinsic for on-chain execution; if not provided, it will perform a dry run and return the result.
  61. \-\-storage-deposit-limit *storage-deposit-limit*
  62. Specifies the maximum amount of balance that can be charged from the caller to pay for the storage consumed.
  63. \-\-output-json
  64. Specifies whether to export the call output in JSON format.
  65. \-\-help, -h
  66. This displays a short description of all the options
  67. Subcommands:
  68. ++++++++++++
  69. Upload Subcommand
  70. -----------------
  71. This subcommand enables the uploading of contracts onto the Polkadot blockchain.
  72. .. code-block:: bash
  73. aqd polkadot upload --suri //Alice -x flipper.contract --output-json
  74. Instantiate Subcommand
  75. ----------------------
  76. This subcommand facilitates the instantiation of contracts on the Polkadot blockchain.
  77. .. code-block:: bash
  78. aqd polkadot instantiate --suri //Alice --args true -x --output-json --skip-confirm flipper.contract
  79. Options specific to the ``instantiate`` subcommand:
  80. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81. \-\-constructor *constructor*
  82. Specifies the name of the contract constructor to call. [default: new]
  83. \-\-args *<args>...*
  84. Accepts a space separated list of values, encoded in order as the arguments of the constructor to invoke.
  85. \-\-value *value*
  86. Specifies the value to be transferred as part of the call. [default: 0]
  87. \-\-gas *gas*
  88. Specifies the maximum amount of gas to be used for this command.
  89. \-\-proof-size *proof-size*
  90. Specifies the maximum proof size for this instantiation.
  91. \-\-salt *salt*
  92. Specifies a salt used in the address derivation of the new contract.
  93. -y, \-\-skip-confirm
  94. When set, skips the interactive confirmation prompt.
  95. Call Subcommand
  96. ---------------
  97. This subcommand enables the calling of contracts on the Polkadot blockchain.
  98. .. code-block:: bash
  99. aqd polkadot call --contract 5EFYe3hkH2wFK1mLxD5VSqD88hfPZWihXAKeqozZELsL4Ueq --message get --suri //Alice flipper.contract --output-json --skip-confirm
  100. Options specific to the ``call`` subcommand:
  101. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. \-\-contract *contract*
  103. Specifies the address of the contract to call.
  104. -m, \-\-message *message*
  105. Specifies the name of the contract message to call.
  106. \-\-args *<args>...*
  107. Accepts a space separated list of values, encoded in order as the arguments of the message to invoke.
  108. \-\-value *value*
  109. Specifies the value to be transferred as part of the call. [default: 0]
  110. \-\-gas *gas*
  111. Specifies the maximum amount of gas to be used for this command.
  112. \-\-proof-size *proof-size*
  113. Specifies the maximum proof size for this call.
  114. -y, \-\-skip-confirm
  115. When set, skips the interactive confirmation prompt.
  116. Remove Subcommand
  117. -----------------
  118. This subcommand allows for the removal of contracts from the Polkadot blockchain.
  119. .. code-block:: bash
  120. aqd polkadot remove --suri //Alice --output-json --code-hash 0x94e67200d3d8f0f420873f8d1b426fdf5eb87f208c6e5d061822e017ffaef2a8 flipper.contract
  121. Options specific to the ``remove`` subcommand:
  122. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  123. \-\-code-hash *code_hash*
  124. Specifies the code hash to remove.
  125. Interacting with Solana running programs on-chain
  126. _________________________________________________
  127. The command line syntax for interacting with a program deployed on Solana is as follows:
  128. aqd solana [SUBCOMMAND] [OPTIONS]...
  129. It consists of a subcommand followed by its options, both of which are described below.
  130. .. note::
  131. Solang Aqd relies on the local default Solana configuration file to obtain information for transaction submissions.
  132. For comprehensive management of this configuration file, you can refer to `Solana's CLI command documentation <https://docs.solana.com/cli/usage#solana-config>`_.
  133. General Options (for all subcommands):
  134. ++++++++++++++++++++++++++++++++++++++
  135. \-\-output-json
  136. Specifies whether to export the call output in JSON format.
  137. \-\-help, -h
  138. This displays a short description of all the options.
  139. Subcommands:
  140. ++++++++++++
  141. Deploy Subcommand
  142. ------------------
  143. Allows you to deploy Solana compiled programs to Solana.
  144. .. code-block:: bash
  145. aqd solana deploy flipper.so
  146. Show Subcommand
  147. ---------------
  148. Show information about a Solana program's instructions given an IDL JSON file.
  149. .. code-block:: bash
  150. aqd solana show --idl flipper.json --instruction new
  151. Options specific to the ``show`` subcommand:
  152. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153. \-\-idl *idl-json-file-path*
  154. Specifies the path of the IDL JSON file.
  155. \-\-instruction *instruction-name*
  156. Specifies the name of the instruction to show information about.
  157. If not specified, information about all instructions is shown.
  158. Call Subcommand
  159. ---------------
  160. Allows you to send a custom transaction to a Solana program, enabling the execution of specific functions within the deployed smart contract.
  161. .. code-block:: bash
  162. aqd solana call --idl flipper.json --program G2eBnLvwPCGCFVywrUT2LtKCCYFkGetAVXJfW82UXmPe --instruction new --data true --accounts new self system
  163. 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.
  164. Solang Aqd simplifies this process by accepting these parameters as command-line arguments.
  165. Additionally, it ensures the submitted transaction aligns with the expected values in the Interface Description Language (IDL).
  166. .. note::
  167. If unsure, you can always check the expected arguments and accounts for a specific function by using the ``show`` subcommand.
  168. Options specific to the ``call`` subcommand:
  169. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. \-\-idl *idl-json-file-path*
  171. Specifies the path of the IDL JSON file.
  172. \-\-program *program*
  173. Specifies the program ID of the deployed program.
  174. \-\-instruction *instruction-name*
  175. Specifies the name of the instruction to show information about.
  176. If not specified, information about all instructions is shown.
  177. \-\-program *program*
  178. Specifies the program ID of the deployed program.
  179. \-\-data *<data-arguments>...*
  180. Specifies the data arguments to pass to the instruction.
  181. For arrays and vectors, pass a comma-separated list of values. (e.g. 1,2,3,4).
  182. For structs, pass a JSON string of the struct. (can be a path to a JSON file).
  183. \-\-accounts *<account-arguments>...*
  184. Specifies the accounts arguments to pass to the instruction
  185. Keywords:
  186. new
  187. Creates a new solana account and saves it locally.
  188. self
  189. Reads the default keypair from the local configuration file.
  190. system
  191. Uses the system program ID as the account.
  192. \-\-payer *payer*
  193. Specifies the payer keypair to use for the transaction. [default: local default keypair]