Create resource with script

But I wish it were impossible to exchange below this price.
Then there is always:

To edit the script.

Yes, this line

case _ => true

allows you to edit the script later, because it would allow SetAssetScriptTransactions, among others.

Minimum exchange price is checked here:

e.price >= startPrice * (1 + years)

so it’d be impossible to exchange below this price.

I just did it in testnet.
Yesterday everything works.
I will investigate to see if the problem is due to me

I created new token in testnet with the same script.
It just doesn’t seem to work anymore.

This script only respects a minimum of 10 token units.
If you respect this quota the script allows you to buy sell at any price.
I am confused.

Sorry, I exchanged mainnet height for testnet.

In your script you have to assign the current blockchain height to startHeight:

let startHeight = 562376

The current testnet height can be found at https://testnodes.wavesnodes.com/blocks/height

Because startHeight was too large, years = (height - startHeight) / interval was negative, and startPrice * (1 + years) was always less than any price

1 Like

State check failed. Reason: Fee for TransferTransaction (100000 in WAVES) does not exceed minimal value of 500000 WAVES

I receive this message when I try the transfer (testnet)
The code is:

{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE EXPRESSION #-}
{-# SCRIPT_TYPE ASSET #-}

let startHeight = 584032
let startPrice = 12000000
let interval = 8766 * 60
let exp = 41760 * 60 * 1000

match tx {
case e:ExchangeTransaction =>
let years = (height - startHeight) / interval

      e.price >= startPrice * (1 + years)
      && !isDefined(e.sellOrder.assetPair.priceAsset)
      && e.amount >= 1000000000
case _ => true

}

Hi,

Up your TX fee from 100000 to 500000 and that error should go away.

I understand that it should go away.
But how to send that error away?

You need to set fee = 0.005 WAVES in your TransferTransaction

I ran a test.
In testnet it doesn’t work.
On mainnet it is working.

Can I create scripts for my wallet?
I would like to do:
Only maximum 100 wallets send transfers to my wallet.
A wallet that has reached 100 transfers to my wallet will remain locked for 24 hours.
Can anything be done?
Can anyone help me with the code?

Unfortunately, this cannot be done. Scripts validate only outgoing transactions.

1 Like
let startHeight = 1775745
let startPrice = 100000000
let interval = 8766 * 60
let exp = 41760 * 60 * 1000

match tx {
    case e:ExchangeTransaction =>
        let years = (height - startHeight) / interval

          e.price >= startPrice * (1 + years)
          && !isDefined(e.sellOrder.assetPair.priceAsset)
          && e.amount >= 100000000
    case _ => true
}

How to have this script tradable only in waves?
Example:
mytoken = waves
waves = mytoken
no other pairs allowed.

In this way it works, tested on mainnet

let startHeight = 1777162
let WAVESId = base58'WAVES'
let startPrice = 100000000
let interval = 8766 * 60
let exp = 41760 * 60 * 1000

match tx {
    case e:ExchangeTransaction =>
        let years = (height - startHeight) / interval

          e.price >= startPrice * (1 + years)
          && !isDefined(e.sellOrder.assetPair.priceAsset)
          && e.amount >= 100000000
    case _ => true
}

Mytoken negotiable only with waves, every other pair makes an error.

It is already done:

this line guarantees that your token can be traded with WAVES only

So if I delete this line

&& !isDefined(e.sellOrder.assetPair.priceAsset)

but I add this

let WAVESId = base58'WAVES'

do I get the same thing, or do I need to add more code?

I ran this script, but it continues to be negotiable only with idWAVES

{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE EXPRESSION #-}
{-# SCRIPT_TYPE ASSET #-}

let startHeight = 1817111
let USDId = base58'Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck'
let startPrice = 100000000
let interval = 8766 * 60
let exp = 41760 * 60 * 1000

match tx {
    case e:ExchangeTransaction =>
        let years = (height - startHeight) / interval

          e.price >= startPrice * (1 + years)
          && !isDefined(e.sellOrder.assetPair.priceAsset == USDId)
          && e.amount >= 100000000
    case _ => true
}

Hey there, there’s nobody who knows?