diff --git a/docs/getting-started/calling.md b/docs/getting-started/calling.md index 11e5c4254d..f784a0a3a6 100644 --- a/docs/getting-started/calling.md +++ b/docs/getting-started/calling.md @@ -52,85 +52,83 @@ are emitted if they want clients to be able to pick up on them. ![Contract execution via transaction](/img/events-revive.svg) -## Using the Terminal - When you deployed your contract you received the contract address. Use this to interact with the contract. ```bash Contract Address: 5DXR2MxThkyZvG3s4ubu9yRdNiifchZ9eNV8i6ErGx6u1sea ``` -### 1. `get()` function +Choose your preferred method to call your contract: - - ```bash - cargo contract call - --contract - --message get - --suri //Alice - ``` - - + + Pop CLI provides a simple way to interact with your deployed contracts. + + ### Read contract state (`get()` function) + ```bash pop call contract --contract --message get --suri //Alice ``` - - -### 2. `flip()` function + ### Modify contract state (`flip()` function) - - ```bash - cargo contract call + pop call contract --contract --message flip --execute --suri //Alice ``` + + For more detailed information about Pop CLI contract interaction, see the [Pop CLI call guide](https://learn.onpop.io/contracts/guides/call-your-contract). - + + ### Read contract state (`get()` function) + ```bash - pop call contract + cargo contract call + --contract + --message get + --suri //Alice + ``` + + ### Modify contract state (`flip()` function) + + ```bash + cargo contract call --contract --message flip --execute --suri //Alice ``` - - -:::tip -For more info about interacting with your smart contract using the Pop CLI, [check this out](https://learn.onpop.io/contracts/guides/call-your-contract)! -::: + + Go to https://ui.use.ink/ -## Using the Contracts UI + ### Read contract state (`get()` function) -Go to https://ui.use.ink/ + We set the initial value of the Flipper contract + `value` to `false` when we instantiated the contract. Let's check that this is the case. -### 1. `get()` function + In the **Message to Send** section, select the "**get(): bool**" message and accept the default + values for the other options. -We set the initial value of the Flipper contract -`value` to `false` when we instantiated the contract. Let's check that this is the case. + Press **"Read"** and confirm that it returns the value `false`: -In the **Message to Send** section, select the "**get(): bool**" message and accept the default -values for the other options. + ![An image of Flipper RPC call with false](/img/contracts-ui-4.png) -Press **"Read"** and confirm that it returns the value `false`: + ### Modify contract state (`flip()` function) -![An image of Flipper RPC call with false](/img/contracts-ui-4.png) + So let's make the value turn `true` now! -### 2. `flip()` function + The alternative message to send with the UI is `flip()`. Again, accept the default values for the other options and click **Call contract** -So let's make the value turn `true` now! + ![An image of a Flipper transaction](/img/contracts-ui-5.png) -The alternative message to send with the UI is `flip()`. Again, accept the default values for the other options and click **Call contract** + If the transaction was successful, we should then be able to go back to the `get()` function and see our updated storage: -![An image of a Flipper transaction](/img/contracts-ui-5.png) - -If the transaction was successful, we should then be able to go back to the `get()` function and see our updated storage: - -![An image of Flipper RPC call with true](/img/contracts-ui-6.png) \ No newline at end of file + ![An image of Flipper RPC call with true](/img/contracts-ui-6.png) + + \ No newline at end of file diff --git a/docs/getting-started/compiling.md b/docs/getting-started/compiling.md index fca6ac257d..766c00e8b2 100644 --- a/docs/getting-started/compiling.md +++ b/docs/getting-started/compiling.md @@ -15,14 +15,14 @@ import TabItem from '@theme/TabItem'; Run the following command in your `flipper` directory to compile your smart contract: - + ```bash - cargo contract build + pop build ``` - + ```bash - pop build + cargo contract build ``` @@ -134,14 +134,14 @@ For contracts that are supposed to run in production you should always build the contract with `--release`: - + ```bash - cargo contract build --release + pop build --release ``` - + ```bash - pop build --release + cargo contract build --release ``` @@ -158,14 +158,14 @@ the `--release` flag has to be passed explicitly to `cargo build`. If you created a new project using a template, you can find at the bottom of the lib.rs simple test cases which verify the functionality of the contract. We can quickly test this code is functioning as expected: - + ```bash - cargo contract test + pop test ``` - + ```bash - pop test + cargo contract test ``` diff --git a/docs/getting-started/creating.md b/docs/getting-started/creating.md index 3d42c8cbb9..d47e089e8f 100644 --- a/docs/getting-started/creating.md +++ b/docs/getting-started/creating.md @@ -13,14 +13,14 @@ import TabItem from '@theme/TabItem'; Make sure you have [installed the tooling](./setup.md) and that you are in the working directory, and then run: - + ```bash - cargo contract new flipper + pop new contract ``` - + ```bash - pop new contract + cargo contract new flipper ``` diff --git a/docs/getting-started/deploying.md b/docs/getting-started/deploying.md index a4f1b07c79..8023cbde20 100644 --- a/docs/getting-started/deploying.md +++ b/docs/getting-started/deploying.md @@ -11,127 +11,128 @@ import useBaseUrl from '@docusaurus/useBaseUrl'; ![Rocket Title Picture](/img/title/rocket.svg) Deploying a smart contract is the process of making your contract available on a blockchain so that it can be interacted with by others. In the Polkadot ecosystem, -this involves uploading your compiled contract code to a chain that supports smart contracts (i.e. `pallet-revive`), and then creating an instance of your contract. -This page will guide you through the steps to deploy your ink! contract locally, using both the command line and the Contracts UI. +this involves uploading your compiled contract code to a chain that supports smart contracts (i.e. `pallet-revive`), and then creating an instance of your contract. -# Launch a local node +Smart contract deployment on Polkadot is a little different than on traditional smart contract blockchains. The contract deployment process is split into two steps: -:::tip Pro Tip -The [Pop CLI](https://learn.onpop.io/contracts/guides/deploy) handles the `ink-node` for you, no need to install or launch. -::: - -To deploy your contract locally, you need a running blockchain node that supports ink! smart contracts. The recommended option is `ink-node`, a simple Polkadot blockchain configured with the `pallet-revive` for smart contracts ([learn more](../background/polkadot-sdk.md)). - -After [installing `ink-node`](./setup.md#ink-node), you can start a local development chain by running: - -```bash -ink-node -``` - -**Note:** `ink-node` uses the `--dev` flag by default. You may need to specify the `--dev` flag when running a different chain binary. - - - -You can interact with your node using `cargo-contract`, `pop` or [the Contracts UI](https://ui.use.ink/). If you use the Contracts UI, you have to configure it to connect to the locally running node: - -- Click on the dropdown selector at the top left corner. -- Choose "Local Node". +1. Putting your contract code on the blockchain +2. Creating an instance of your contract -![Connect to local node](/img/contracts-ui-local-node.png) +With this pattern, contract code like the ERC20 standard can be put on the blockchain one single time, but instantiated any number of times. No need to continually upload the same source code over and waste space on the blockchain. -# Set up a Local Polkadot Hub Environment + + + Pop CLI automatically launches a local ink-node in the background when deploying contracts. -You can easily launch a full Polkadot Hub setup locally using the [Pop CLI](https://learn.onpop.io/contracts/guides/deploy). This includes a local relay chain and one or more system parachains, allowing for end-to-end smart contract development and testing. + Deploy your contract with: + ```bash + pop build + pop up --suri //Alice --args true + ``` -To spin up the environment with the Paseo relay chain and system chains like `asset-hub` and `passet-hub`, run: -```bash - pop up paseo -p asset-hub,passet-hub -``` -This command will launch: + For more detailed information about Pop CLI deployment options, see the [Pop CLI deployment guide](https://learn.onpop.io/contracts/guides/deploy). -- A local Paseo relay chain + ### Set up a Local Polkadot Hub Environment -- [Passet Hub](../intro/where-to-deploy.md#passet-hub) as a parachain, connected and ready to deploy smart contracts + You can easily launch a full Polkadot Hub setup locally using the [Pop CLI](https://learn.onpop.io/contracts/guides/deploy). This includes a local relay chain and one or more system parachains, allowing for end-to-end smart contract development and testing. -You can also include additional system parachains in your local environment, such as `people` and `pop`, by extending the command: -```bash - pop up paseo -p asset-hub,passet-hub,people,pop -``` + To spin up the environment with the Paseo relay chain and system chains like `asset-hub` and `passet-hub`, run: + ```bash + pop up paseo -p asset-hub,passet-hub + ``` + This command will launch: -Need more options or configuration details? Check out the CLI help: -```bash - pop up paseo --help -``` + - A local Paseo relay chain -## Deploy the contract + - [Passet Hub](../intro/where-to-deploy.md#passet-hub) as a parachain, connected and ready to deploy smart contracts -Now that we have generated the contract binary from our source code and connected to a local node, we want to deploy this contract onto our local node. + You can also include additional system parachains in your local environment, such as `people` and `pop`, by extending the command: + ```bash + pop up paseo -p asset-hub,passet-hub,people,pop + ``` -Smart contract deployment on Polkadot is a little different than on traditional smart contract blockchains. + Need more options or configuration details? Check out the CLI help: + ```bash + pop up paseo --help + ``` + + -For example, the standard ERC20 token has been deployed to Ethereum thousands of times, sometimes only with changes to the initial configuration (through the Solidity `constructor` function). Each of these instances take up space on the blockchain equivalent to the contract source code size, even though no code was actually changed. + To deploy your contract locally, you need a running blockchain node that supports ink! smart contracts. The recommended option is `ink-node`, a simple Polkadot blockchain configured with the `pallet-revive` for smart contracts ([learn more](../background/polkadot-sdk.md)). -The contract deployment process in Polkadot is split into two steps: + After [installing `ink-node`](./setup.md#ink-node), you can start a local development chain by running: -1. Putting your contract code on the blockchain -2. Creating an instance of your contract + ```bash + ink-node + ``` -With this pattern, contract code like the ERC20 standard can be put on the blockchain one single time, but instantiated any number of times. No need to continually upload the same source code over and waste space on the blockchain. + **Note:** `ink-node` uses the `--dev` flag by default. You may need to specify the `--dev` flag when running a different chain binary. -## Using the Terminal + -With `cargo-contract` or `pop` it's just a simple sequence of: + Once your node is running, deploy your contract: - - ```bash cargo contract build cargo contract instantiate --suri //Alice --args true ``` - + + To deploy your contract locally, you need a running blockchain node that supports ink! smart contracts. The recommended option is `ink-node`, a simple Polkadot blockchain configured with the `pallet-revive` for smart contracts ([learn more](../background/polkadot-sdk.md)). + + After [installing `ink-node`](./setup.md#ink-node), you can start a local development chain by running: + ```bash - pop build - pop up --suri //Alice --args true + ink-node ``` - - -## Using the Contracts UI + **Note:** `ink-node` uses the `--dev` flag by default. You may need to specify the `--dev` flag when running a different chain binary. + + + + You can interact with your node using the Contracts UI. Configure it to connect to the locally running node: -### 1. Upload Contract Code + - Click on the dropdown selector at the top left corner. + - Choose "Local Node". -Here we will upload the contract code and instantiate one copy of the contract on the blockchain (which is usually why we upload the contract code in the first place): + ![Connect to local node](/img/contracts-ui-local-node.png) -- Go to https://ui.use.ink/ -- Make sure you have ink! v6 selected in the sidebar -- Click the **Add New Contract** button in the sidebar. -- Click the **Upload New Contract Code** button in the Add New Contract page. -- Choose an **Instantiation account** (e.g. ALICE). -- Give the contract a descriptive **Name** (e.g. Flipper Contract). -- Drag the `flipper.contract` file that contains the bundled binary blob and metadata into the drag & drop area. You will see the UI parse the metadata and enabling the button that takes you to the next step. -- Click the **Next** button + ### 1. Upload Contract Code -![Flipper Instantiate Contract 01](/img/contracts-ui-0.png) + Here we will upload the contract code and instantiate one copy of the contract on the blockchain (which is usually why we upload the contract code in the first place): -### 2. Instantiate a Contract on the Blockchain + - Go to https://ui.use.ink/ + - Make sure you have ink! v6 selected in the sidebar + - Click the **Add New Contract** button in the sidebar. + - Click the **Upload New Contract Code** button in the Add New Contract page. + - Choose an **Instantiation account** (e.g. ALICE). + - Give the contract a descriptive **Name** (e.g. Flipper Contract). + - Drag the `flipper.contract` file that contains the bundled binary blob and metadata into the drag & drop area. You will see the UI parse the metadata and enabling the button that takes you to the next step. + - Click the **Next** button -Smart contracts exist as an extension of the account system on the blockchain. Thus creating an instance of this contract will create a new `AccountId` (ETH-compatible address) which will store any balance managed by the smart contract and allow us to interact with the contract. + ![Flipper Instantiate Contract 01](/img/contracts-ui-0.png) -Now a screen displays the information that represents our smart contract. We are going to instantiate a copy of the smart contract: + ### 2. Instantiate a Contract on the Blockchain -- Accept the default options for the contract **Deployment Constructor**. -- Accept the default options **Max Gas Allowed** of `200000`. -- Click on `Next` + Smart contracts exist as an extension of the account system on the blockchain. Thus creating an instance of this contract will create a new `AccountId` (ETH-compatible address) which will store any balance managed by the smart contract and allow us to interact with the contract. -![Flipper Instantiate Contract 02](/img/contracts-ui-1.png) + Now a screen displays the information that represents our smart contract. We are going to instantiate a copy of the smart contract: -The transaction is now queued, review your data and click **Upload and Instantiate** or go back and modify your inputs. + - Accept the default options for the contract **Deployment Constructor**. + - Accept the default options **Max Gas Allowed** of `200000`. + - Click on `Next` -![Flipper Instantiate Contract 03](/img/contracts-ui-2.png) + ![Flipper Instantiate Contract 02](/img/contracts-ui-1.png) -You will be redirected to a new page, where you can interact with the newly created contract instance. + The transaction is now queued, review your data and click **Upload and Instantiate** or go back and modify your inputs. + + ![Flipper Instantiate Contract 03](/img/contracts-ui-2.png) + + You will be redirected to a new page, where you can interact with the newly created contract instance. + + ![Flipper Instantiate Success](/img/contracts-ui-3.png) + + -![Flipper Instantiate Success](/img/contracts-ui-3.png) diff --git a/docs/getting-started/setup.md b/docs/getting-started/setup.md index a34a481f61..a039cfefa8 100644 --- a/docs/getting-started/setup.md +++ b/docs/getting-started/setup.md @@ -23,7 +23,16 @@ A pre-requisite for compiling smart contracts is to install a stable Rust version (>= 1.85) and `cargo`. Please see [the official Rust installation guide](https://doc.rust-lang.org/cargo/getting-started/installation.html). - + + ## Pop CLI + Use the [Pop CLI](https://learn.onpop.io/contracts/welcome/install-pop-cli) for ink! smart contract development with the greatest developer experience. + + Pop CLI supports ink! v6 through the polkavm-contracts feature flag: + ```bash + cargo install pop-cli --no-default-features --locked -F polkavm-contracts,parachain,telemetry + ``` + + ## cargo-contract The first tool we will be installing is [`cargo-contract`](https://github.com/use-ink/cargo-contract), @@ -37,55 +46,45 @@ version (>= 1.85) and `cargo`. Please see [the official Rust installation guide] ```bash rustup update stable ``` - - - ## Pop CLI - Use the [Pop CLI](https://learn.onpop.io/contracts/welcome/install-pop-cli) for ink! smart contract development with the greatest developer experience. - Pop CLI supports ink! v6 through the polkavm-contracts feature flag: - ```bash - cargo install pop-cli --no-default-features --locked -F polkavm-contracts,parachain,telemetry - ``` - - + ## ink-node + The [ink-node](https://github.com/use-ink/ink-node) is + a simple Polkadot SDK blockchain with smart contract functionality. It's a comfortable option for local development and testing. -## ink-node + There are two ways of installing the node: -The [ink-node](https://github.com/use-ink/ink-node) is -a simple Polkadot SDK blockchain with smart contract functionality. It's a comfortable option for local development and testing. + ### (1) Download the Binary + Go to the [ink-node releases page](https://github.com/use-ink/ink-node/releases). Under `Assets` of the latest release, download the appropriate binary for your platform: + - **Linux (ARM64)**: `ink-node-linux-arm64.tar.gz` + - **Linux (x86)**: `ink-node-linux.tar.gz` + - **macOS**: `ink-node-mac-universal.tar.gz` -There are two ways of installing the node: + Make the binary executable: + ```bash + chmod +x ./ink-node + ``` -### (1) Download the Binary -Go to the [ink-node releases page](https://github.com/use-ink/ink-node/releases). Under `Assets` of the latest release, download the appropriate binary for your platform: - - **Linux (ARM64)**: `ink-node-linux-arm64.tar.gz` - - **Linux (x86)**: `ink-node-linux.tar.gz` - - **macOS**: `ink-node-mac-universal.tar.gz` + **For macOS users:** + When you first try to run `ink-node`, macOS may show a security warning. -Make the binary executable: - ```bash - chmod +x ./ink-node - ``` + To allow the binary to run: + 1. Click the **question mark (?)** icon at the right top corner of the warning. + 2. Follow the Apple instructions that appear. + 3. Try running `ink-node` again and click **"Open Anyway"** when prompted. -**For macOS users:** -When you first try to run `ink-node`, macOS may show a security warning. - -To allow the binary to run: -1. Click the **question mark (?)** icon at the right top corner of the warning. -2. Follow the Apple instructions that appear. -3. Try running `ink-node` again and click **"Open Anyway"** when prompted. - -To confirm that `ink-node` is working correctly, run: -```bash -./ink-node --version -``` -If you see version information, your installation is successful! + To confirm that `ink-node` is working correctly, run: + ```bash + ./ink-node --version + ``` + If you see version information, your installation is successful! -### (2) Build it yourself + ### (2) Build it yourself -Alternatively, you can build the node by yourself. -This can take a while though! + Alternatively, you can build the node by yourself. + This can take a while though! -The build instructions and pre-requisites can be found -[here](https://github.com/use-ink/ink-node?tab=readme-ov-file#build-locally). \ No newline at end of file + The build instructions and pre-requisites can be found + [here](https://github.com/use-ink/ink-node?tab=readme-ov-file#build-locally). + + \ No newline at end of file