waves_logo Docs
  • Overview
    Overview
  • How-to Guides
    • Reading Blockchain Data
      Reading Blockchain Data
    • Creating & Broadcasting Transactions
      Creating & Broadcasting Transactions
    • Tokenization
      Tokenization
    • Airdrop
      Airdrop
    • Payments
      Payments
    • Exchange Tokens
      Exchange Tokens
    • Simple Voting
      Simple Voting
    • List as argument
      List as argument
    How-to Guides
  • Waves Smart Contracts
    Waves Smart Contracts
  • dApp
    • Creating & Launching dApp
      Creating & Launching dApp
    dApp
  • Smart Account
    • Creating smart account
      Creating smart account
    • Creating and deploying a script manually
      Creating and deploying a script manually
    • Video tutorials
      • Introduction to the Waves blockchain, Waves Smart Accounts and Waves Smart Assets
        Introduction to the Waves blockchain, Waves Smart Accounts and Waves Smart Assets
      • Waves Smart Account with multisignature
        Waves Smart Account with multisignature
      • Waves Smart Account with escrow service
        Waves Smart Account with escrow service
      • Creating multisignature account via Waves IDE tools
        Creating multisignature account via Waves IDE tools
      • Creating multisignature account via Waves Client
        Creating multisignature account via Waves Client
      • Waves console explained
        Waves console explained
      Video tutorials
    Smart Account
  • Smart Asset
    Smart Asset
  • Developer Tools
    • Waves IDE
      Waves IDE
    • Visual Studio Code Extension
      Visual Studio Code Extension
    • Surfboard
      Surfboard
    • Ride REPL
      Ride REPL
    Developer Tools
  • Signer ◆
    Signer ◆
  • Waves API
    • Data Service API
      Data Service API
    • Node REST API
      Node REST API
    • Node gRPC Server
      Node gRPC Server
    • Blockchain Updates
      Blockchain Updates
    Waves API
  • Client Libraries
    • Waves C#
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Waves C#
    • Gowaves
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Gowaves
    • WavesJ
      • Install SDK
        Install SDK
      WavesJ
    • Ts-lib-crypto
      • Install SDK
        Install SDK
      Ts-lib-crypto
    • Waves-PHP
      • Install SDK
        Install SDK
      Waves-PHP
    • Waves-python
      • Install SDK
        Install SDK
      Waves-python
    • Waves-rust
      • Install SDK
        Install SDK
      Waves-rust
    Client Libraries
      • English
      • Русский
      On this page
        • Prerequisites
        • Tutorial
      waves_logo Docs

          # Set Up Smart Contracts

          Deploy a smart contract after meeting the prerequisites.

          # Prerequisites

          • Wallet: Set up a wallet via Keeper Wallet or WX Network .

            NOTE: Ensure saving your wallet's seed phrase to send transactions.

          • Tokens: Obtain WAVES tokens to cover the transaction fee for each script deployment:
            • For the Mainnet network: Get 0.001 WAVES via Available Market Options .
            • For the Testnet network: Get 0.001 WAVES via Faucet .
            • For the Stagenet network: Get 0.001 WAVES via Faucet .

          # Tutorial

          Follow the steps for the relevant smart contract type:

          • dApp.
          • Smart Account.
          • Smart Asset.

          # Deploy dApp Script

          1. Prepare your dApp script:
            // Script example:
            {-# STDLIB_VERSION 8 #-}
            {-# CONTENT_TYPE DAPP #-}
            {-# SCRIPT_TYPE ACCOUNT #-}
            
            @Callable(i)
            func checkStorageUntouchedByAlias(accountAlias: String) = {
                let alias = Alias(accountAlias)
                let res = if isDataStorageUntouched(alias) then {
                    unit
                } else {
                    throw("Data storage is not untouched by the alias")
                }
                ([], res)
            }
            
          2. Send a Set Script Transaction with:
          • Your seed phrase pasted into the seedPhrase variable.
          • Your dApp script pasted into the rideScript variable.
            // Example of the ride script formatted:
            rideScript := `
                {-# STDLIB_VERSION 8 #-}
                {-# CONTENT_TYPE EXPRESSION #-}
                {-# SCRIPT_TYPE ACCOUNT #-}
                        
                let cooperPubKey = base58'BVqYXrapgJP9atQccdBPAgJPwHDKkh6A8'
                let BTCId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
                match tx {
                    case o: Order =>
                        sigVerify(o.bodyBytes, o.proofs[0], cooperPubKey ) && (o.assetPair.priceAsset == BTCId || o.assetPair.amountAsset == BTCId)
                    case _ => sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey )
                }
            `
            

          # Deploy Smart Account Script

          1. Prepare your smart asset script:
            // Script example:
            {-# STDLIB_VERSION 6 #-}
            {-# CONTENT_TYPE EXPRESSION #-}
            {-# SCRIPT_TYPE ACCOUNT #-}
            
            let cooperPubKey = base58'BVqYXrapgJP9atQccdBPAgJPwHDKkh6A8'
            let BTCId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
            match tx {
                case o: Order =>
                    sigVerify(o.bodyBytes, o.proofs[0], cooperPubKey ) && 
                    (o.assetPair.priceAsset == BTCId || o.assetPair.amountAsset == BTCId)
                case _ => sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey )
            };
            
          2. Send a Set Script Transaction with:
          • Your seed phrase pasted into the seedPhrase variable.
          • Your smart asset script pasted into the rideScript variable.
            // Example of the ride script formatted:
            rideScript := `
                {-# STDLIB_VERSION 8 #-}
                {-# CONTENT_TYPE EXPRESSION #-}
                {-# SCRIPT_TYPE ACCOUNT #-}
            		
                let cooperPubKey = base58'BVqYXrapgJP9atQccdBPAgJPwHDKkh6A8'
                let BTCId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
                match tx {
                    case o: Order =>
                        sigVerify(o.bodyBytes, o.proofs[0], cooperPubKey ) && (o.assetPair.priceAsset == BTCId || o.assetPair.amountAsset == BTCId)
                    case _ => sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey )
                }
            

          # Deploy Smart Asset Script

          1. Prepare your smart asset script:
            // Script example:
            {-# STDLIB_VERSION 6 #-}
            {-# CONTENT_TYPE EXPRESSION #-}
            {-# SCRIPT_TYPE ASSET #-}
            
            func trueReturner () = {
                true
            }
            
            trueReturner()
            
          2. Follow the steps based on your goal:
          • To create a new smart asset with the defined script.
          • To add a smart asset script to an existing asset.

          # Create Smart Asset

          Send an Issue Transaction with:

          • Your seed phrase pasted into the seedPhrase variable.
          • Your smart asset script pasted into the rideScript variable.
            // Formatting example:
            rideScript := `
                {-# STDLIB_VERSION 6 #-}
                {-# CONTENT_TYPE EXPRESSION #-}
                {-# SCRIPT_TYPE ASSET #-}
            		
                func trueReturner () = {
                    true
                }
            
                trueReturner()
            `
            

          # Add Asset Script

          Send a Set Asset Script Transaction with:

          • Your seed phrase pasted into the seedPhrase variable.
          • Your asset ID pasted into the assetID variable.
          • Your smart asset script pasted into the rideScript variable.
            // Formatting example:
            rideScript := `
                {-# STDLIB_VERSION 6 #-}
                {-# CONTENT_TYPE EXPRESSION #-}
                {-# SCRIPT_TYPE ASSET #-}
            		
                func trueReturner () = {
                    true
                }
            
                trueReturner()
            `
            
          Interact With Node
          WavesJ
          Interact With Node
          WavesJ