### Start Tezos Docker Container
Source: https://docs.tezos.com/tutorials/smart-rollup/set-up
This command starts a Docker container from the 'tezos/tezos:master' image. It mounts the current directory into the container, opens an interactive shell, and sets up the Octez environment for use.
```bash
docker run -it --rm --volume $(pwd):/home/tezos/hello-world-kernel --entrypoint /bin/sh --name octez-container tezos/tezos:master
```
--------------------------------
### Install App Dependencies and Start Dev Server
Source: https://docs.tezos.com/tutorials/build-an-nft-marketplace/part-1
Navigates to the 'app' directory, installs project dependencies using 'yarn', and starts the development server using 'yarn dev'. This command is used to run the frontend React application.
```bash
cd app
yarn && yarn dev
```
--------------------------------
### Project Setup and Compilation Instructions
Source: https://docs.tezos.com/tutorials/dapp/part-4
Provides instructions for setting up and compiling the Tezos project. It involves installing dependencies using npm and suggests using the CLI for further interaction and testing.
```bash
npm i
```
--------------------------------
### Clone Tezos Kernel Repository
Source: https://docs.tezos.com/tutorials/smart-rollup/set-up
This command clones the 'hello-world-kernel' repository from GitLab, which contains the tutorial application. It's the first step in setting up the project.
```bash
git clone https://gitlab.com/trili/hello-world-kernel.git
cd hello-world-kernel/
```
--------------------------------
### Install Svelte with TypeScript and Vite
Source: https://docs.tezos.com/tutorials/build-your-first-app/setting-up-app
Initializes a new Svelte project using Vite and TypeScript, then installs the project dependencies. This sets up the basic structure for the application.
```bash
npm create vite@latest bank-tutorial -- --template svelte
cd bank-tutorial
npm install
```
--------------------------------
### Install Tezos-related Dependencies
Source: https://docs.tezos.com/tutorials/build-your-first-app/setting-up-app
Installs essential Tezos libraries including Taquito for Tezos interaction and Beacon Wallet for wallet connectivity. These are crucial for building a Tezos dApp.
```bash
npm install @taquito/taquito @taquito/beacon-wallet @airgap/beacon-types
```
--------------------------------
### Initialize Taqueria Project and Install Plugins
Source: https://docs.tezos.com/tutorials/build-an-nft-marketplace/part-1
Initializes a new Taqueria project named 'nft-marketplace', navigates into the project directory, and installs the LIGO and Taquito plugins. These plugins are essential for smart contract development and interaction on the Tezos blockchain.
```bash
taq init nft-marketplace
cd nft-marketplace
taq install @taqueria/plugin-ligo
taq install @taqueria/plugin-taquito
```
--------------------------------
### Install Dependencies and Start Development Server
Source: https://docs.tezos.com/tutorials/dapp/part-2
This snippet provides the commands to install project dependencies using Yarn and then start the local development server for the frontend application. It assumes the user is in the `app` directory.
```bash
cd app
yarn install
yarn dev
```
--------------------------------
### Svelte Component Structure Example
Source: https://docs.tezos.com/tutorials/build-your-first-app/setting-up-app
Demonstrates the basic structure of a Svelte component, which includes distinct sections for JavaScript/TypeScript logic, CSS styling, and HTML markup. This illustrates how Svelte components encapsulate different code types.
```svelte
```
--------------------------------
### Install Vite Compatibility Libraries
Source: https://docs.tezos.com/tutorials/build-your-first-app/setting-up-app
Installs development dependencies for buffer, events, and a Vite-compatible readable stream. These are necessary polyfills for certain Node.js modules in a Vite environment.
```bash
npm install --save-dev buffer events vite-compatible-readable-stream
```
--------------------------------
### Verify Tezos Tools in Docker Container
Source: https://docs.tezos.com/tutorials/smart-rollup/set-up
These commands verify that the necessary Tezos command-line tools (Octez node, debugger, smart rollup node, and client) are installed and accessible within the running Docker container.
```bash
octez-node --version
octez-smart-rollup-wasm-debugger --version
octez-smart-rollup-node --version
octez-client --version
```
--------------------------------
### Install FA2 Token Library with Taqueria
Source: https://docs.tezos.com/tutorials/build-an-nft-marketplace/part-1
Installs the '@ligo/fa' library, which provides FA2 token templates for creating fungible and non-fungible tokens on Tezos. This involves updating the 'ligo.json' file and using Taqueria with a specific LIGO Docker image to perform the installation.
```bash
echo '{ "name": "app", "dependencies": { "@ligo/fa": "^1.4.2" } }' >> ligo.json
TAQ_LIGO_IMAGE=ligolang/ligo:1.6.0 taq ligo --command "install @ligo/fa"
```
--------------------------------
### Run Octez Client from Docker Image
Source: https://docs.tezos.com/developing/octez-client/installing
Starts a Docker container using the latest `tezos/tezos` image and opens an interactive shell within it. This allows you to use the Octez client and other Tezos tools without installing them directly on your host system.
```bash
docker run -it --rm --entrypoint /bin/sh --name octez-container tezos/tezos:latest
```
--------------------------------
### Rust: Install Rustup
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/set-up-environment
Installs Rust and the `rustup` toolchain manager using a script downloaded from the official Rust website. It ensures `curl` is installed first.
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
--------------------------------
### Build Tezos WASM Application
Source: https://docs.tezos.com/tutorials/smart-rollup/set-up
This command compiles the Rust application specifically for the 'wasm32-unknown-unknown' target. Successful compilation results in a WASM file in the 'target' directory.
```bash
cargo build --target wasm32-unknown-unknown
```
--------------------------------
### Pull Tezos Octez Docker Image
Source: https://docs.tezos.com/tutorials/smart-rollup/set-up
This command pulls the latest Tezos Docker image, which includes the Octez client. This image is essential for interacting with the Tezos network and running the tutorial application within a controlled environment.
```bash
docker pull tezos/tezos:master
```
--------------------------------
### Verify Octez Client Installation
Source: https://docs.tezos.com/developing/octez-client/installing
Checks if the Octez client has been successfully installed by querying its version. A successful execution will display the installed version number, confirming that the client is ready for use.
```bash
octez-client --version
```
--------------------------------
### Install Taquito and TzKT Dependencies
Source: https://docs.tezos.com/tutorials/dapp/part-1
Installs the necessary Taquito and TzKT SDK libraries for interacting with the Tezos blockchain and its indexer. Also installs development dependencies for types.
```bash
cd app
yarn add @taquito/taquito @taquito/beacon-wallet @airgap/beacon-sdk @tzkt/sdk-api
yarn add -D @airgap/beacon-types
```
--------------------------------
### Smart Rollup Deployment Script
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/get-dal-params
A shell script to automate the build, installation, and deployment of a Smart Rollup. It compiles the Rust code, prepares the installer, originates the rollup, and starts the observer node. It takes the wallet alias as an argument.
```bash
#!/bin/sh
alias="${1}"
set -e
cargo build --release --target wasm32-unknown-unknown
rm -rf _rollup_node
cp target/wasm32-unknown-unknown/release/files_archive.wasm .
smart-rollup-installer get-reveal-installer -P _rollup_node/wasm_2_0_0 \
-u files_archive.wasm -o installer.hex
octez-client originate smart rollup files_archive from "${alias}" of kind wasm_2_0_0 \
of type unit with kernel "$(cat installer.hex)" --burn-cap 2.0 --force
octez-smart-rollup-node run observer for files_archive \
with operators --data-dir _rollup_node \
--dal-node http://localhost:10732 --log-kernel-debug
```
--------------------------------
### Docker: Start Tezos Container
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/set-up-environment
Starts an interactive Docker container from the `tezos/tezos` image, setting the entrypoint to `/bin/sh` for shell access.
```bash
docker run -it --entrypoint=/bin/sh tezos/tezos:latest
```
--------------------------------
### Initialize Taqueria Project and Install Plugins
Source: https://docs.tezos.com/tutorials/dapp/part-1
Commands to set up a new Taqueria project, navigate into its directory, and install essential plugins for LIGO smart contract development and Taquito integration. This establishes the foundational environment for dApp creation.
```bash
taq init training
cd training
taq install @taqueria/plugin-ligo
taq install @taqueria/plugin-taquito
taq create contract pokeGame.jsligo
```
--------------------------------
### Install Tezos DAL Trusted Setup
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/get-slot-info
Installs the trusted setup for the Tezos DAL node. This command configures the necessary cryptographic parameters. For Octez versions prior to 21.1, the `--legacy` flag must be included.
```bash
./install_dal_trusted_setup.sh
```
```bash
./install_dal_trusted_setup.sh --legacy
```
--------------------------------
### SmartPy: Create a View to Get a Value from a Big-Map
Source: https://docs.tezos.com/allPageSourceFiles
This SmartPy contract defines a view `getValue` that retrieves a value from a big-map storage based on an address key. The view is annotated with `@sp.onchain_view` and returns a default value of 0 if the key is not found. The example also includes an `add` entrypoint to modify the big-map and test setup to demonstrate contract functionality.
```python
@sp.module
def main():
storage_type: type = sp.big_map[sp.address, sp.nat]
class MyContract(sp.Contract):
def __init__(self):
self.data = sp.big_map()
sp.cast(self.data, storage_type)
@sp.entrypoint
def add(self, addr, value):
currentVal = self.data.get(addr, default=0)
self.data[addr] = currentVal + value
@sp.onchain_view
def getValue(self, addr):
return self.data.get(addr, default=0)
@sp.add_test()
def test():
scenario = sp.test_scenario("Callviews", main)
contract = main.MyContract()
scenario += contract
alice = sp.test_account("Alice")
bob = sp.test_account("Bob")
# Test the entrypoint
contract.add(addr = alice.address, value = 5)
contract.add(addr = alice.address, value = 5)
contract.add(addr = bob.address, value = 4)
scenario.verify(contract.data[alice.address] == 10)
scenario.verify(contract.data[bob.address] == 4)
# Test the view
scenario.verify(contract.getValue(alice.address) == 10)
scenario.verify(contract.getValue(bob.address) == 4)
```
--------------------------------
### Create Svelte Project and Install Dependencies
Source: https://docs.tezos.com/tutorials/create-nfts/setting-up-app
Commands to create a new Svelte project using Vite, install Tezos SDK dependencies (@taquito/taquito, @taquito/utils, @taquito/beacon-wallet, @airgap/beacon-types), and necessary polyfills (buffer, events, vite-compatible-readable-stream).
```bash
npm create vite@latest create-nfts -- --template svelte
cd create-nfts
npm install
npm install @taquito/taquito @taquito/utils @taquito/beacon-wallet @airgap/beacon-types
npm install --save-dev buffer events vite-compatible-readable-stream
```
--------------------------------
### Taqueria: Install Contract Types Plugin
Source: https://docs.tezos.com/tutorials/build-an-nft-marketplace/part-1
Installs the '@taqueria/plugin-contract-types' plugin for Taqueria. This plugin is used to generate TypeScript types for smart contracts.
```bash
taq install @taqueria/plugin-contract-types
```
--------------------------------
### Git Clone Training Repository
Source: https://docs.tezos.com/tutorials/build-an-nft-marketplace/part-1
Clones the Marigold Dev training repository for the NFT project. This repository contains a starter React application and a completed version for reference.
```bash
git clone https://github.com/marigold-dev/training-nft-1.git
```
--------------------------------
### Make Tezos DAL Setup Scripts Executable
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/get-slot-info
Sets execute permissions for the downloaded Tezos DAL trusted setup scripts. This step is required before running the installation script.
```bash
chmod +x install_dal_trusted_setup.sh version.sh
```
--------------------------------
### Initialize App.svelte Component
Source: https://docs.tezos.com/tutorials/build-your-first-app/setting-up-app
Replaces the default `src/App.svelte` file with a minimal Svelte component structure. This file will serve as the main container for other Svelte components and will be expanded later to include wallet connection logic.
```svelte
```
--------------------------------
### Clone Repository and Initialize Taqueria Project
Source: https://docs.tezos.com/tutorials/mobile/part-1
This snippet demonstrates how to clone the Shifumi training DApp repository and initialize a new Taqueria project, including installing the LIGO plugin.
```bash
git clone https://github.com/marigold-dev/training-dapp-shifumi.git
taq init shifumi
cd shifumi
taq install @taqueria/plugin-ligo
```
--------------------------------
### Compile and Call Smart Contract Initialization
Source: https://docs.tezos.com/tutorials/dapp/part-4
Compiles the LIGO smart contract and then calls its initialization entrypoint with a specified parameter file on the testing environment.
```bash
TAQ_LIGO_IMAGE=ligolang/ligo:1.6.0 taq compile pokeGame.jsligo
taq call pokeGame --param pokeGame.parameter.default_parameter.tz -e testing
```
--------------------------------
### Install Ionic CLI and Create React App
Source: https://docs.tezos.com/tutorials/mobile/part-2
Installs the Ionic command-line interface globally and creates a new blank Ionic React application. This is the initial step for setting up the project structure.
```bash
npm install -g @ionic/cli
ionic start app blank --type react
```
--------------------------------
### Start Smart Rollup Node (Observer Mode)
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/get-dal-params
Command to start the Smart Rollup node in observer mode for a specific rollup. This mode does not require a stake to publish commitments. It assumes a local node at http://127.0.0.1:8732, with an option to specify a different endpoint.
```bash
octez-smart-rollup-node run observer for files_archive \
with operators --data-dir ./_rollup_node --log-kernel-debug
```
--------------------------------
### Start Octez Client Mockup Mode
Source: https://docs.tezos.com/tutorials/smartpy-fa2-fungible/basic-fa2-token
Initializes the Octez client in mockup mode, creating a local sandbox environment for contract testing. This command sets up a base directory and protocol for the mockup.
```bash
octez-client \
--protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK \
--base-dir /tmp/mockup \
--mode mockup \
create mockup
```
--------------------------------
### Complex Nested JSON Parameter Example for Tezos
Source: https://docs.tezos.com/unity/calling-contracts
Illustrates a complex, nested Micheline parameter structure in JSON format, suitable for Tezos operations. This example represents a parameter that starts with a string, followed by an array of pairs, where each pair contains an integer and a string. Block explorers can help generate such formats.
```json
{
"prim": "Pair",
"args": [
{
"string": "My string"
},
[
{
"prim": "Pair",
"args": [
{
"int": "5"
},
{
"string": "String one"
}
]
},
{
"prim": "Pair",
"args": [
{
"int": "9"
},
{
"string": "String two"
}
]
},
{
"prim": "Pair",
"args": [
{
"int": "12"
},
{
"string": "String three"
}
]
}
]
]
}
```
--------------------------------
### Create Local Wallet and Fund with Faucet
Source: https://docs.tezos.com/allPageSourceFiles
Demonstrates creating a local wallet account using the Octez client and then funding it from the network's faucet. This is essential for participating in test network activities.
```bash
octez-client gen keys my_account
# Fund it with the network faucet
```
--------------------------------
### Replace Main JavaScript Entry Point
Source: https://docs.tezos.com/tutorials/build-your-first-app/setting-up-app
Replaces the default `src/main.js` file with code that mounts the main Svelte App component to the document body. This serves as the primary entry point for the Svelte application.
```javascript
import { mount } from 'svelte';
import './app.css'
import App from './App.svelte';
const app = mount(App, { target: document.body });
export default app
```
--------------------------------
### Execute Smart Rollup Deployment Script
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/get-dal-params
Example command to execute the deployment script. The script requires the Octez client account alias as a parameter.
```bash
./deploy_smart_rollup.sh my_wallet
```
--------------------------------
### Configure Rust for WASM Compilation
Source: https://docs.tezos.com/tutorials/smart-rollup/set-up
These commands configure your Rust environment to build WebAssembly applications. It ensures you are using the correct Rust version and adds the 'wasm32-unknown-unknown' target.
```bash
rustup override set 1.73.0
rustup target add wasm32-unknown-unknown
```
--------------------------------
### Configure Taquito with RPC Node
Source: https://docs.tezos.com/dApps/taquito
Initializes the TezosToolkit with a specific RPC node URL. This setup is essential for Taquito to communicate with the Tezos blockchain. The example uses the public Shadownet node.
```typescript
import { TezosToolkit } from '@taquito/taquito'
const Tezos = new TezosToolkit('https://rpc.shadownet.teztnets.com')
```
--------------------------------
### Svelte: Setting Up App.svelte Main Content
Source: https://docs.tezos.com/tutorials/create-nfts/setting-up-app
This code replaces the default main content of the App.svelte file with a simple H1 heading, 'Create NFTs'. This is a foundational step in building the user interface for the application.
```svelte
Create NFTs
```
--------------------------------
### Initialize Svelte App Entry Point
Source: https://docs.tezos.com/tutorials/create-nfts/setting-up-app
Replaces the default code in `src/main.js` to import necessary stylesheets and mount the main `App.svelte` component. This script targets the `document.body` to inject the application's HTML, deviating from the default Svelte behavior of using a `div` tag.
```javascript
import './app.css'
import { mount } from 'svelte';
import App from './App.svelte'
const app = mount(App, { target: document.body });
export default app
```
--------------------------------
### Write unit tests for PokeGame contract
Source: https://docs.tezos.com/tutorials/dapp/part-2
Example of a unit test file for the PokeGame contract written in .jsligo. It includes setup, test functions, and assertions to verify contract behavior.
```javascript
#import "./pokeGame.jsligo" "PokeGame"
export type main_fn = module_contract;
// reset state
const _ = Test.reset_state(2 as nat, list([]) as list);
const faucet = Test.nth_bootstrap_account(0);
const sender1: address = Test.nth_bootstrap_account(1);
const _2 = Test.log("Sender 1 has balance : ");
const _3 = Test.log(Test.get_balance_of_address(sender1));
const _4 = Test.set_baker(faucet);
const _5 = Test.set_source(faucet);
export const initial_storage = {
pokeTraces: Map.empty as map,
feedback: "kiss"
};
export const initial_tez = 0mutez;
//functions
export const _testPoke = (
taddr: typed_address,
s: address
): unit => {
const contr = Test.to_contract(taddr);
const contrAddress = Tezos.address(contr);
Test.log("contract deployed with values : ");
Test.log(contr);
Test.set_source(s);
const status = Test.transfer_to_contract(contr, Poke(), 0 as tez);
Test.log(status);
const store: PokeGame.storage = Test.get_storage(taddr);
Test.log(store);
//check poke is registered
match(Map.find_opt(s, store.pokeTraces)) {
when (Some(pokeMessage)):
do {
assert_with_error(
pokeMessage.feedback == "",
"feedback " + pokeMessage.feedback + " is not equal to expected "
+ "(empty)"
);
assert_with_error(
pokeMessage.receiver == contrAddress,
"receiver is not equal"
);
}
when (None()):
assert_with_error(false, "don't find traces")
};
};
// TESTS //
const testSender1Poke =
(
(): unit => {
const orig =
Test.originate(contract_of(PokeGame), initial_storage, initial_tez);
_testPoke(orig.addr, sender1);
}
)();
```
--------------------------------
### Octez: Initialize Node Configuration
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/set-up-environment
Initializes the Octez node's configuration for the Ghostnet network. This sets up the necessary files for the node to connect to Ghostnet.
```bash
octez-node config init --network ghostnet
```
--------------------------------
### Get Account Balance with Taquito
Source: https://docs.tezos.com/allPageSourceFiles
Retrieves the current balance of a Tezos account in mutez using the `getBalance` method from `TezosToolkit`. This method requires the account's address as a string and returns the balance as a `BigNumber` object. Ensure you have installed `@taquito/taquito` and `bignumber.js`.
```typescript
import { TezosToolkit } from '@taquito/taquito'
import { BeaconWallet } from '@taquito/beacon-wallet'
import type { BigNumber } from 'bignumber.js'
const Tezos = new TezosToolkit('https://rpc.shadownet.teztnets.com')
const wallet = new BeaconWallet(OPTIONS)
await wallet.requestPermissions()
Tezos.setWalletProvider(wallet)
// gets the user's address
const userAddress = await wallet.getPKH()
// gets their balance
const balance: BigNumber = await Tezos.tz.getBalance(userAddress)
```
--------------------------------
### Verify Clang Installation and Target Support
Source: https://docs.tezos.com/tutorials/build-files-archive-with-dal/set-up-environment
Commands to verify the installed Clang version and check if the `wasm32` target is supported. These are crucial steps after setting up the compiler.
```shell
$CC --version
$CC -print-targets | grep wasm32
```
--------------------------------
### Svelte Component Structure with Script, Style, and Main
Source: https://docs.tezos.com/tutorials/create-nfts/setting-up-app
This snippet shows the basic structure of a Svelte component file, including placeholders for JavaScript/TypeScript, SCSS styles, and HTML content. Svelte components encapsulate their logic, styles, and markup.
```svelte
```
--------------------------------
### Get Current Tezos Block Level
Source: https://docs.tezos.com/tutorials/join-dal-baker/verify-rights
This command fetches the current block level of the Tezos chain. This value is used as the starting point for the loop that checks for DAL shard assignments in future blocks.
```bash
octez-client rpc get /chains/main/blocks/head | jq '.header.level'
```