# 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:
# Deploy dApp
- 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) }
- Send a Set Script Transaction with:
- Your seed phrase pasted into the
seedPhrase
variable. - Your dApp script pasted into the
scriptSource
variable.// Example of the ride script formatted: String scriptSource = "{-# STDLIB_VERSION 8 #-}\n" + "{-# CONTENT_TYPE DAPP #-}\n" + "{-# SCRIPT_TYPE ACCOUNT #-}\n\n" + "@Callable(i)\n" + "func checkStorageUntouchedByAlias(accountAlias: String) = {\n" + " let alias = Alias(accountAlias)\n" + " let res = if isDataStorageUntouched(alias) then {\n" + " unit\n" + " } else {\n" + " throw(\"Data storage is not untouched by the alias\")\n" + " }\n" + " ([], res)\n" + "}";
# Deploy Smart Account
- 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 ) };
- Send a Set Script Transaction with:
- Your seed phrase pasted into the
seedPhrase
variable. - Your smart asset script pasted into the
scriptSource
variable.// Example of the ride script formatted: String scriptSource = "{-# STDLIB_VERSION 6 #-}\n" + "{-# CONTENT_TYPE EXPRESSION #-}\n" + "{-# SCRIPT_TYPE ACCOUNT #-}\n\n" + "let cooperPubKey = base58'BVqYXrapgJP9atQccdBPAgJPwHDKkh6A8'\n" + "let BTCId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'\n" + "match tx {\n" + " case o: Order =>\n" + " sigVerify(o.bodyBytes, o.proofs[0], cooperPubKey ) && \n" + " (o.assetPair.priceAsset == BTCId || o.assetPair.amountAsset == BTCId)\n" + " case _ => sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey )\n" + "};";
# Deploy Smart Asset Script
- Prepare your smart asset script:
// Script example: {-# STDLIB_VERSION 6 #-} {-# CONTENT_TYPE EXPRESSION #-} {-# SCRIPT_TYPE ASSET #-} func trueReturner () = { true } trueReturner()
- 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
scriptSource
variable.// Formatting example: String scriptSource = "{-# STDLIB_VERSION 6 #-}\n" + "{-# CONTENT_TYPE EXPRESSION #-}\n" + "{-# SCRIPT_TYPE ASSET #-}\n\n" + "func trueReturner () = {\n" + " true\n" + "}\n\n" + "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
scriptSource
variable.// Formatting example: String scriptSource = "{-# STDLIB_VERSION 6 #-}\n" + "{-# CONTENT_TYPE EXPRESSION #-}\n" + "{-# SCRIPT_TYPE ASSET #-}\n\n" + "func trueReturner () = {\n" + " true\n" + "}\n\n" + "trueReturner()";