/Ink_hands-on

Hands on exercises to accompany the lectures

Primary LanguageTypeScript

Built with ink!

Ink! hands-on exercises

Companion to the PBA ink! Smart Contrcts smodule

Prerequisites

  1. Have docker and docker-compose (1.29.2)
  2. Have cargo-contract (3.2.0) installed:
cargo install cargo-contract --vers 3.2.0

Install polkadot{.js} extension.

Add these two accounts:

  1. Alice (bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice)
  2. Bob (bottom drive obey lake curtain smoke basket hold race lonely fit walk//Bob)

Running a node locally

make devnode

Escrow Smart Contract

To compile:

make compile

To deploy e.g. escrow contract:

deploy escrow

Deployed contracts write their addresses to the addresses.json file in the root directory. You can copy the address and use it in the https://contracts-ui.substrate.io/contract

Testnet

To deploy a given command run on the Azero Testnet preceed it with the name of the environment:

AZERO_ENV=testnet make <command>

Upgradeable contracts

  1. Deploy the old_a contract:
AZERO_ENV=testnet make deploy-old-a
  1. Import and query it using the https://ui.use.ink/add-contract UI dashboard.
  2. Upgrade the contract:
AZERO_ENV=testnet make upgrade-a
  1. Query the state again
  2. Take a look at the set_code call in the old contract and try to understand it.
  • what is the raw cross-contract call doing?
  • what happens if it fails?
  • why is it important to use the ManualKey in contracts storage here?
  • Could you achieve a similar upgrade without using Lazy?

Testnet faucet

https://faucet.test.azero.dev/

Cargo contract calls

cargo contract call --url wss://ws.test.azero.dev --contract <address> --message get_values --suri "//Alice" --skip-confirm