Brief Summary
- Smart Asset is an asset that has a script (it’s issued with a script specified in IssueTransaction; the fee is equal to 1 waves). A smart asset’s script cannot be set to null.
- The script validates each transaction that involves this asset. Each validation of a specific transaction by a smart asset’s script increases the transaction’s fee by 0.004 waves.
- 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.
- Sponsorship of smart assets is prohibited.
Motivation
Currently, we have smart accounts that allow to flexibly control transactions on a certain address. Smart Accounts are implemented with scripts and we're considering applying scripts to assets as well.Similar to Smart Accounts, Smart assets are assets with a script which validates every transaction with the asset.
We probably are going to add this feature and we want to discuss it. We want to hear your opinion on the following questions:
1. Do you think this feature is needed? Would you use it? What for?
2. Should scripts be changeable?
3. Do you have any concerns or suggestions regarding this feature?
Use Cases
Smart assets can be used in the following cases:- Asset freeze (till the certain height or date).
- Whitelist/blacklist (allow/deny to transfer to certain addresses).
- Taxation. Issuer gets a share after each transaction (via Sponsorship in a special asset).
- Multi-signature (the asset’s issuer has to approve (co-sign) every transaction).
- Controlling Asset Pairs (tokens interchangeable with a certain currency only).
- Gaming: transfer an asset only under certain conditions (holder has a certain attribute/is in a certain location).
- Require assets’ owners to use a specific matcher.
- A token that indicates some commitment/debt (unburnable, may only be transferred back with permission of the issuer).
Implementation
Issue a Smart Asset
A smart asset is issued via IssueTransactionV2 and its script is set at once. Issue fee is 1 WAVES, as for non-scripted asset.
The differences between IssueTransactionV2 and IssueTransactionV1 are:
- In V2 fields version and script were added.
- IssueTransactionV2 supports proofs so signature was replaced with proofs.
The following is an example of an IssueTransaction (version 2) that issues a smart asset:
{
"type" : 3,
"version" : 2,
"senderPublicKey" : "rWaQhEMTz6saZmZwLR3iuLBhCU2QSq51QmfTX9Je2Mk",
"name" : "mySmartAsset",
"description" : "unburnable smart asset",
"quantity" : 2000000,
"decimals" : 6,
"reissuable" : true,
"fee" : 100000000,
"timestamp" : 1537456619027,
"script" : "base64:AQQAAAAHJG1hdGNoMAUAAAACdH",
"proofs" : ["3fP2NNKtqRjJQsVXkhXKFcdU7YvRBrJ4Ren6tg8a3g1wuctrfp8PfDap6"]
}
Change Asset Script
It’s proposed to allow setting scripts to smart assets only. It means that if an asset was issued without a script then a script cannot be added later. A smart asset’s script can be changed via SetAssetScriptTransaction:
{
"type" : 15,
"id" : "EXDKRNL5Apiw3K9mvLjPVNTWRhDwEvzeA9GAXSrYfQsh",
"assetId" : "L5Apiw3K9mvLjPVNTWRhDwEvzeA9GAEXDKRNXSrYfQsh",
"sender" : "3N9dfiTb8Pd6hqhvXaf8GcdTxdwCAeyxsvr",
"senderPublicKey" : "6gT9PnyXA2sQ9AyRYn1QqkquWSu44Hr3qzLxszchTD1J",
"fee" : 100000000,
"timestamp" : 1535102049904,
"proofs" : [ "4QwRFUNZUk7KaWGnmnYp6pUqUrLjZk3hFwhQTaJN7SUAYDvmXVkU4DDWadH5pQWkaUYiAdCQFtqSKZyKwyaUdyUN" ],
"version" : 1,
"script" : "base64:AQQAAAALYWxpY2FANpZ25lZAUAAAAJYm9iU2lnbmVkB5fCpHI"
}
Only issuer can change an asset’s script. A smart asset’s script cannot be set to null. The required fee for SetAssetScriptTransaction is 1 WAVES.
To create an asset that behaves as non-scripted but can be upgraded later, issue an asset with script: ‘true’.
Transaction Fee
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.Sponsorship
We suggest prohibiting sponsorship of SmartAssets because it would complicate the process of verifying transactions and can have unexpected side effects.Trading
Trading on SmartAssets is allowed (node validates every ExchangeTransaction using scripts of the two assets in AssetPair).Validation
A smart asset’s script validates any of the following transaction types with the asset:
- ReissueTransaction
- BurnTransaction
- TransferTransaction
- MassTransferTransaction
- ExchangeTransaction
- SetAssetScriptTransaction
SetSponsorshipTransactions are not validated with an asset’s script, because Sponsorship of smart assets is denied.