Smart Assets Proposal

Brief Summary

  1. 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.
  2. 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.
  3. 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’.
  4. 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.
  5. 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:
  1. Asset freeze (till the certain height or date).
  2. Whitelist/blacklist (allow/deny to transfer to certain addresses).
  3. Taxation. Issuer gets a share after each transaction (via Sponsorship in a special asset).
  4. Multi-signature (the asset’s issuer has to approve (co-sign) every transaction).
  5. Controlling Asset Pairs (tokens interchangeable with a certain currency only).
  6. Gaming: transfer an asset only under certain conditions (holder has a certain attribute/is in a certain location).
  7. Require assets’ owners to use a specific matcher.
  8. 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:

  1. In V2 fields version and script were added.
  2. 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:

  1. ReissueTransaction
  2. BurnTransaction
  3. TransferTransaction
  4. MassTransferTransaction
  5. ExchangeTransaction
  6. SetAssetScriptTransaction

SetSponsorshipTransactions are not validated with an asset’s script, because Sponsorship of smart assets is denied.

8 Likes

Examples of scripts for smart assets

  1. Issue an unburnable asset:
match tx {
  case t : BurnTransaction => false
  case _ => true
}
  1. Taxation:
match tx {
  case t : MassTransferTransaction =>
    let twoTransfers = size(t.transfers) == 2
    let issuerIsRecipient = t.transfers[0].recipient == addressFromString("3MgkTXzD72BTfYpd9UW42wdqTVg8HqnXEfc")
    let taxesPaid = t.transfers[0].amount >= t.transfers[1].amount / 10
    twoTransfers && issuerIsRecipient && taxesPaid
  case _ => false
}
  1. Freeze your assets till the certain height:
let targetHeight = 1500000
height >= targetHeight
  1. Whitelist transfer recipients:
match tx {
  case t : TransferTransaction =>
    let trustedRecipient1 = addressFromString("3P6ms9EotRX8JwSrebeTXYVnzpsGCrKWLv4")
    let trustedRecipient2 = addressFromString("3PLZcCJyYQnfWfzhKXRA4rteCQC9J1ewf5K")
    let trustedRecipient3 = addressFromString("3PHrS6VNPRtUD8MHkfkmELavL8JnGtSq5sx")
    t.recipient == trustedRecipient1 || t.recipient == trustedRecipient2 || t.recipient == trustedRecipient3
  case _ => false
}
  1. Blacklist transfer recipients:
match tx {
  case t : TransferTransaction =>
    let bannedRecipient1 = addressFromString("3P6ms9EotRX8JwSrebeTXYVnzpsGCrKWLv4")
    let bannedRecipient2 = addressFromString("3PLZcCJyYQnfWfzhKXRA4rteCQC9J1ewf5K")
    let bannedRecipient3 = addressFromString("3PHrS6VNPRtUD8MHkfkmELavL8JnGtSq5sx")
    t.recipient != bannedRecipient1 && t.recipient != bannedRecipient2 && t.recipient != bannedRecipient3
  case _ => false
}
  1. Require a fee in a certain asset to get a share after each transfer:
match tx {
  case t : TransferTransaction =>
    t.feeAssetId == base58'oWgJN6YGZFtZrV8BWQ1PGktZikgg7jzGmtm16Ktyvjd'
  case _ => true
}
  1. Token that can be only transferred with the issuer’s permission (commitment/debt label):
match tx {
  case t : TransferTransaction =>
    let issuer = addressFromString("3P6ms9EotRX8JwSrebeTXYVnzpsGCrKWLv4")
    isDefined(getInteger(issuer, toString(t.id)))
  case _ => false
}
  1. Issue an untransferable asset:
match tx {
  case t : TransferTransaction | MassTransferTransaction | ExchangeTransaction => false
  case _ => true
}
  1. Asset tradable only with BTC:
let BTCId = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
match tx {
  case t : ExchangeTransaction =>
    t.sellOrder.assetPair.priceAsset == BTCId || t.sellOrder.assetPair.amountAsset == BTCId
  case _ => true
}
  1. Require using a certain matcher:
match tx {
  case t : ExchangeTransaction =>
    t.sender == addressFromString("3PJaDyprvekvPXPuAtxrapacuDJopgJRaU3")
  case _ => true
}
7 Likes

great feature for regulated projects. you should consider to release that.

We really need it and would add nice and new functionality to the platform

I agree with @karmenali, great features for projects looking to work according to compliance and regulation. Would love to see that on MainNet!

Hi all,

I also think that this is a very important feature, maybe even more important than Smart Accounts, especially if you look from a project perspective.

Just to add one use case, if you think of Utility Tokens, it might make sense to make a token not tradable:

match tx { 
  case tx : Order => false 
  case tx : ExchangeTransaction => false
  case _ => true
}

Cheers
Marc

1 Like

I think most all know my position on smart assets, but let me add that it will further diversify the project from others.

With smart assets, posibilities for the colored tokens we already have are as limitless as Waves, this makes Waves a huge competitor for ERC20.

These features are probably over 90% of all smart contract use cases on ethereum, also feature 2 is extremely important to security token issuers so that will open doors for whole new wave of users

Alloowing communities to vote on original tokens that are non reissuable in order to make them smart assets might slso be a great idea.

It’s all nice, but my only concern is that having Smart Assets and Smart Accounts is little confusing. The separation, 2 entities, is confusing. Why don’t have simply Smart contracts which are applied for assets or accounts. I think the naming is confusing.

There are projects that exist on waves who already would want some or all of these features. These are almost ‘basic’ ones when comparing other chains and major competition. Ease, availability don’t matter if there is no functionality.

1 Like

Hi @Valique,

Do you have any specific examples of the projects who already would want to add these features to their existing assets?

Taxation can have many use case. Freeze asset can help ico runner to avoid from quick dump. Whitelist and blacklist will be like using centralized chain, that will help regulated works to avoid from money loundry “fiat gateways can benefit from that”. We can add features 7-9-10 to this. Banks, goverments and companies can benefit from that as well.

Everyone can benefit from that don’t need a specific usecase. we will not know until the needs are satisfied with this feature.

Apis is currently using a second token to lock up assets for a year on their hives waiting for smart assets.

The current implementation allows setting scripts to smart assets only. It means that if an asset was issued without a script then a script cannot be added later. To create an asset that behaves as non-scripted but can be upgraded later, it’s suggested to issue an asset with the script ‘true’.
Do you think that the ability to add scripts to existing assets (that are currently in use and don’t have scripts) is necessary?

Yeah great for Banking to come in must be easy for them to understand but it’s a must fiat will flow if we get Banks to commit.

Ok, i see a very frustrating thing here: spam tokens which you cannot control at all.

Nowadays you can burn or send not needed tokens away, but with smart assets it is possible to create an absolutely immovable tokens and spam them as before.

This changes the paradigm as you can’t protect your account from that.

I do not like this feature alone without some restrict mechanism against it.

1 Like

Even now you can’t actually control spam tokens. You just make it invisible. You will be able put the spam tokens in spam box even if they issiued with smart assets.
I never burned a spam token they are all in spam box. Spam box is just a filter. There are many way to avoid from spams, the client can be redisgn to show only tokens that you want to see in your wallet. Also transactions only for specific tokens that you want to see on desktop wallet. You guys have a lack of imagination against problems. And really make me dissapoint in this project. Free your mind and start to think what we can do with Smart assets.

It is not a trivial UI question.

The question is in the paradigm, that you can control anything with your private key in your account. You can even block yourself with smart account script. But it is your choice.

Now you telling me that there will be tokens that I can’t do anything with. It is frustrating.