- Smart Assets Definition
- Smart Assets Features
- Smart Assets Use Cases
- Smart Asset Fees
- Trading
- Validation
- Examples of Scripts for Smart Assets
Smart assets are unique virtual currency tokens that may represent a tangible real-world asset, or a non-tangible ownership that can be purchased, sold, or exchanged as defined by the rules of a script on the Waves blockchain network.
In simple words, Smart assets are assets with an attached script which validates every transaction within that asset.
- Smart assets will allow to apply constraints on all operations for a specific asset.
- Smart assets will offer a great degree of autonomy, anonymity, and low-cost of transactions.
Smart assets can be used in the following cases:
- Freezing assets: It is similar to keeping the assets untouched for a particular interval of time or for a certain height, This is useful in case of having multiple funding rounds.
- Whitelist/blacklist: Giving the possibility to allow/deny making a transfer for specific addresses.
- Taxation: The issuer can get a share after each transaction.
- Multi-signature: It's a digital signature scheme which allows a group of users to sign a transaction, It requires another user or users to sign a transaction before it can be broadcast onto the blockchain.
- Controlling Asset Pairs: Tokens interchangeable with a certain currency only.
- Gaming: The smart asset can be used to transfer an asset only under certain conditions (holder has a certain attributes in a certain location).
- A token that indicates some commitment/debt (unburnable, may only be transferred back with permission of the issuer).
- Require asset's owners to use a specific matcher.
The transaction fee is calculated in the same way as for smart accounts: for each time the script is called, total transaction’s fee increases by 0.004 WAVES.
Examples:
- If user will transfer smart assets from scripted account the final fee is 0.009.waves
- x for a TransferTransaction of a Smart Asset from a Smart Account would be 0.001+0.004+0.004=0.009 WAVES
Note. If a scripted account transfers a smart asset, then the fee is increased twice (the fee increases +0.004 every time the transaction is validated by account’s script or asset’s script).
Trading on SmartAssets is allowed (node validates every ExchangeTransaction using scripts of the two assets in AssetPair).
If an Asset Pair contains a Smart Asset then the fee is increased by + 0.004 (+0.008 if both assets are smart). It doesn't matter if any of the accounts is a SmartAccount, SmartAccounts pay in the same way as non-smart Accounts do.
Asset Pair | Fee |
---|---|
Asset / Asset | 0.003 |
Asset / SmartAsset | 0.003 + 0.004 = 0.007 |
SmartAsset / SmartAsset | 0.003 + 0.008 = 0.011 |
This fee is payed to the Matcher by every account that is placing an order. The same fee is payed by the Matcher when an ExchangeTransaction is put into the blockchain.
If an ExchangeTransaction's sender (the Matcher or any other account) has a script then the total fee for the transaction is increased by 0.004 waves.
A smart asset’s script validates any of the following transaction types with the asset:
- ReissueTransaction
- BurnTransaction
- TransferTransaction
- MassTransferTransaction
- ExchangeTransaction
- SetAssetScriptTransaction
Note. Smart Assets scripts do not validate orders. Therefore, although RIDE allows to use case t : Order => …
branch, in fact this branch does not validate anything when used in SmartAssets’ scripts and will be ignored. So all the logic regarding orders should be moved to case t : ExchangeTransaction => …
branch. The Sponsorship of smart assets is prohibited.
You can create a smartAsset via IssueTransaction(Version2) and specify the script in this transaction.
Here’s an example of JSON for IssueTransaction(Version2):
{
"type" : 3,
"version" : 2,
"senderPublicKey" : "rWaQhEMTz6saZmZwLR3iuLBhCU2QSq51QmfTX9Je2Mk",
"name" : "mySmartAsset",
"description" : "my smart asset",
"quantity" : 2000000,
"decimals" : 6,
"reissuable" : true,
"fee" : 100000000,
"timestamp" : 1537456619027,
"script" : "base64:AQa3b8tH", // the compiled script “true”
"proofs" : ["3fP2NNKtqRjJQsVXkhXKFcdU7YvRBrJ4Ren6tg8a3g1wuctrfp8PfDap6"]
}
Note
The assets that were issued without a script cannot become scripted. You can create an asset that behaves as non-scripted but can be upgraded later, by issuing an asset with a script: 'true'.
A smart asset’s script can be changed via SetAssetScriptTransaction (fee on changing is equal to 1 WAVES).
Only the issuer can change the asset's script.
You can find an example of _**SetAssetScript **_transaction on testnet in the following transactions examples.
For issue an unburnable asset you can use pattern matching with a false
value to BurnTransaction:
match tx {
case t : BurnTransaction => false
case _ => true
}
You can freeze your assets till the certain height by defining a target height variable:
let targetHeight = 1500000
height >= targetHeight
For requiring a fee in a certain asset to get a share after each transfer you can use TransferTransaction depending on the asset id:
match tx {
case t : TransferTransaction =>
t.feeAssetId == base58'oWgJN6YGZFtZrV8BWQ1PGktZikgg7jzGmtm16Ktyvjd'
case _ => true
}
You can restrict the token transfer option to be done only by the token issuer's permission (commitment/debt label):
match tx {
case t : TransferTransaction =>
let issuer = addressFromString("3P6ms9EotRX8JwSrebeTXYVnzpsGCrKWLv4")
isDefined(getInteger(issuer, toString(t.id)))
case _ => false
}
To make the asset untransferable, you can assign a false
value to TransferTransaction, MassTransferTransaction and ExchangeTransaction:
match tx {
case t : TransferTransaction | MassTransferTransaction | ExchangeTransaction => false
case _ => true
}
To allow asset trading only with bitcoins you can do as here:
let BTCId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
match tx {
case t : ExchangeTransaction =>
t.sellOrder.assetPair.priceAsset == BTCId || t.sellOrder.assetPair.amountAsset == BTCId
case _ => true
}
To define a certain matcher, you can assign the matcher address as a sender value:
match tx {
case t : ExchangeTransaction =>
t.sender == addressFromString("3PJaDyprvekvPXPuAtxrapacuDJopgJRaU3")
case _ => true
}